Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
118943 | 毛泓博(做题专用,大号Fess) | 收集雨水 | C++ | 解答错误 | 10 | 3 MS | 308 KB | 306 | 2024-01-02 13:58:18 |
#include<bits/stdc++.h> using namespace std; int n,a[10001],ans; stack<int>s; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; int m=a[i]; while(!s.empty()&&a[s.top()]<=m) { m=min(m,a[s.top()]); ans+=m-a[s.top()]+1; s.pop(); } s.push(i); } cout<<ans; }