# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36471 | 2017-12-09T09:24:37 Z | szawinis | Money (IZhO17_money) | C++14 | 0 ms | 9828 KB |
#include <bits/stdc++.h> using namespace std; const int MAX = (1e6)+1; int n, ans, a[MAX], f[MAX]; void update(int i) { ++i; while(i < MAX) ++f[i], i += i & -i; } int query(int i) { ++i; int ret = 0; while(i > 0) ret += f[i], i -= i & -i; return ret; } int main() { scanf("%d",&n); for(int i = 0, last = 0; i < n; i++) { scanf("%d",a+i); if(i && (a[i] < a[i-1] || query(a[i]-1) - query(a[last]))) { ++ans; while(last < i) update(a[last++]); } } printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |