# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38585 | 2018-01-04T15:35:30 Z | MrPlany | Money (IZhO17_money) | C++14 | 0 ms | 9828 KB |
#include <iostream> using namespace std; const int N = 1e6+5; int n,a[N],t[N]; int sum(int k){ int s=0; while(k>0){ s+=t[k]; k-=k&-k; } return s; } int add(int k, int val){ while(k<N){ t[k]+=val; k+=k&-k; } } int main(){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; int ans = 0; for(int i=1;i<=n;i++){ int l,r;l = r = i; while( a[r+1]>=a[r] && sum(a[r]) - sum(a[l]-1)<=0) r++; ans++; while(l<=r) add(a[l++],1); i=r; } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |