# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
35146 | 2017-11-18T10:45:45 Z | Pajaraja | Money (IZhO17_money) | C++14 | 0 ms | 9828 KB |
#include <bits/stdc++.h> using namespace std; int bit[1000007],a[1000007],n; void upd(int x) { while(x<=n) { bit[x]++; x+=(x&-x); } } int sum(int x) { int s=0; while(x>0) { s+=bit[x]; x-=(x&-x); } return s; } bool ima(int l,int r) {return sum(r-1)>sum(l);} int main() { int cnt=1,last=0; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); for(int i=1;i<n;i++) { if(a[i]<a[i-1] || ima(a[last],a[i])) { cnt++; while(last<i) upd[a[last++]]; } } printf("%d",cnt); }
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 | - |