# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
541333 |
2022-03-23T06:45:29 Z |
AlperenT |
Po (COCI21_po) |
C++17 |
|
13 ms |
3412 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, arr[N], nxt[N], upd[N], cur, ans;
stack<int> stck;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++) cin >> arr[i];
stck.push(n + 1);
for(int i = n; i >= 1; i--){
while(arr[stck.top()] >= arr[i]) stck.pop();
nxt[i] = stck.top();
stck.push(i);
}
for(int i = 1; i <= n; i++){
cur += upd[i];
if(cur == arr[i]) continue;
else{
upd[nxt[i]] -= arr[i] - cur;
ans++;
cur += arr[i] - cur;
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 11 |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
4 |
Runtime error |
4 ms |
980 KB |
Execution killed with signal 11 |
5 |
Runtime error |
6 ms |
1232 KB |
Execution killed with signal 11 |
6 |
Correct |
12 ms |
2360 KB |
Output is correct |
7 |
Runtime error |
13 ms |
3412 KB |
Execution killed with signal 11 |