# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38204 | 2018-01-03T04:03:39 Z | Talant | Money (IZhO17_money) | C++14 | 0 ms | 9828 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define OK puts("OK"); #define pb push_back #define mk make_pair using namespace std; typedef long long ll; const ll inf = (ll)1e9 + 7; const int N = (int)1e6 + 7; int n; int a[N],t[N],lst = 1; int ans; void update (int pos) { for (; pos <= n; pos += (pos & (-pos))) t[pos] ++; } int get (int pos) { int res = 0; for (; pos > 0; pos -= (pos & (-pos))) res += t[pos]; return res; } int main () { cin >> n; for (int i = 1; i <= n; i ++) scanf ("%d", &a[i]); update (a[1]); for (int i = 2; i <= n; i ++) { if (a[i] > a[i - 1]) { update (a[i]); int o = get(a[i]) - get(a[lst] - 1); if (i - lst + 1 != o) { ans ++; lst = i; } } else { update (a[i]); lst = i; ans ++; } } ans ++; cout << ans << endl; } /** 6 3 6 4 5 1 2 **/
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 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
5 | 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 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
5 | 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 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
5 | 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 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |