# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36461 | 2017-12-09T08:10:58 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]; vector<pair<int,int> > segs; void update(int i) { while(i < MAX) ++f[i], i += i & -i; } int query(int i) { int ret = 0; while(i > 0) ret += f[i], i -= i & -i; return ret; } int main() { scanf("%d",&n); int curr = 0; for(int i = 0; i < n; i++) { scanf("%d",a+i); if(i && a[i] < a[i-1]) { segs.emplace_back(curr, i-1); curr = i; } } segs.emplace_back(curr, n-1); for(auto p: segs) { int l, r; tie(l, r) = p; ++ans; for(int i = l; i <= r; i++) { if(i > l && a[i] - a[i-1] > 1 && query(a[i]-1) - query(a[i-1])) ++ans; update(a[i]); } } printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Correct | 0 ms | 9828 KB | Output is correct |
3 | Correct | 0 ms | 9828 KB | Output is correct |
4 | Correct | 0 ms | 9828 KB | Output is correct |
5 | Correct | 0 ms | 9828 KB | Output is correct |
6 | Correct | 0 ms | 9828 KB | Output is correct |
7 | Correct | 0 ms | 9828 KB | Output is correct |
8 | Correct | 0 ms | 9828 KB | Output is correct |
9 | Correct | 0 ms | 9828 KB | Output is correct |
10 | Correct | 0 ms | 9828 KB | Output is correct |
11 | Correct | 0 ms | 9828 KB | Output is correct |
12 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Correct | 0 ms | 9828 KB | Output is correct |
3 | Correct | 0 ms | 9828 KB | Output is correct |
4 | Correct | 0 ms | 9828 KB | Output is correct |
5 | Correct | 0 ms | 9828 KB | Output is correct |
6 | Correct | 0 ms | 9828 KB | Output is correct |
7 | Correct | 0 ms | 9828 KB | Output is correct |
8 | Correct | 0 ms | 9828 KB | Output is correct |
9 | Correct | 0 ms | 9828 KB | Output is correct |
10 | Correct | 0 ms | 9828 KB | Output is correct |
11 | Correct | 0 ms | 9828 KB | Output is correct |
12 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Correct | 0 ms | 9828 KB | Output is correct |
3 | Correct | 0 ms | 9828 KB | Output is correct |
4 | Correct | 0 ms | 9828 KB | Output is correct |
5 | Correct | 0 ms | 9828 KB | Output is correct |
6 | Correct | 0 ms | 9828 KB | Output is correct |
7 | Correct | 0 ms | 9828 KB | Output is correct |
8 | Correct | 0 ms | 9828 KB | Output is correct |
9 | Correct | 0 ms | 9828 KB | Output is correct |
10 | Correct | 0 ms | 9828 KB | Output is correct |
11 | Correct | 0 ms | 9828 KB | Output is correct |
12 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Correct | 0 ms | 9828 KB | Output is correct |
3 | Correct | 0 ms | 9828 KB | Output is correct |
4 | Correct | 0 ms | 9828 KB | Output is correct |
5 | Correct | 0 ms | 9828 KB | Output is correct |
6 | Correct | 0 ms | 9828 KB | Output is correct |
7 | Correct | 0 ms | 9828 KB | Output is correct |
8 | Correct | 0 ms | 9828 KB | Output is correct |
9 | Correct | 0 ms | 9828 KB | Output is correct |
10 | Correct | 0 ms | 9828 KB | Output is correct |
11 | Correct | 0 ms | 9828 KB | Output is correct |
12 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |