# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92558 | 2019-01-03T11:59:07 Z | Nodir_Bobiev | Simple game (IZhO17_game) | C++14 | 192 ms | 5400 KB |
# include <iostream> # include <cstdio> using namespace std; const int N = 1e5 + 100; const int M = 1e6; int n, m, t; int h[N]; int d[M + 1]; void update(int x, int s) { while(x <= M){ d[x] += s; x += (x & -x); } } int get(int x){ int s = 0; while(x > 0){ s += d[x]; x -= (x & -x); } return s; } int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", h + i); for (int i = 1; i < n; i++){ int l, r; l = min(h[i], h[i + 1]); r = max(h[i], h[i + 1]); update(l, +1); update(r + 1, -1); } while(m--){ int pos, val, l, r, H; scanf("%d", &t); if(t == 1){ scanf("%d %d", &pos, &val); if(pos != 1){ l = min(h[pos], h[pos - 1]); r = max(h[pos], h[pos - 1]); update(l, -1); update(r + 1, +1); l = min(val, h[pos - 1]); r = max(val, h[pos - 1]); update(l, +1); update(r + 1, -1); } if(pos != n){ l = min(h[pos], h[pos + 1]); r = max(h[pos], h[pos + 1]); update(l, -1); update(r + 1, +1); l = min(val, h[pos + 1]); r = max(val, h[pos + 1]); update(l, +1); update(r + 1, -1); } h[pos] = val; } else{ scanf("%d", &H); cout << get(H) << endl; } } } /* 3 3 1 5 1 2 3 1 1 5 2 3 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 3832 KB | Output is correct |
3 | Correct | 6 ms | 3960 KB | Output is correct |
4 | Correct | 6 ms | 3960 KB | Output is correct |
5 | Correct | 6 ms | 3832 KB | Output is correct |
6 | Correct | 6 ms | 3960 KB | Output is correct |
7 | Correct | 4 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 3832 KB | Output is correct |
3 | Correct | 6 ms | 3960 KB | Output is correct |
4 | Correct | 6 ms | 3960 KB | Output is correct |
5 | Correct | 6 ms | 3832 KB | Output is correct |
6 | Correct | 6 ms | 3960 KB | Output is correct |
7 | Correct | 4 ms | 376 KB | Output is correct |
8 | Correct | 168 ms | 888 KB | Output is correct |
9 | Correct | 192 ms | 5292 KB | Output is correct |
10 | Correct | 189 ms | 5400 KB | Output is correct |
11 | Correct | 170 ms | 888 KB | Output is correct |
12 | Correct | 172 ms | 1372 KB | Output is correct |
13 | Correct | 171 ms | 1400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 3832 KB | Output is correct |
3 | Correct | 6 ms | 3960 KB | Output is correct |
4 | Correct | 6 ms | 3960 KB | Output is correct |
5 | Correct | 6 ms | 3832 KB | Output is correct |
6 | Correct | 6 ms | 3960 KB | Output is correct |
7 | Correct | 4 ms | 376 KB | Output is correct |
8 | Correct | 168 ms | 888 KB | Output is correct |
9 | Correct | 192 ms | 5292 KB | Output is correct |
10 | Correct | 189 ms | 5400 KB | Output is correct |
11 | Correct | 170 ms | 888 KB | Output is correct |
12 | Correct | 172 ms | 1372 KB | Output is correct |
13 | Correct | 171 ms | 1400 KB | Output is correct |
14 | Correct | 147 ms | 4956 KB | Output is correct |
15 | Correct | 142 ms | 5008 KB | Output is correct |
16 | Correct | 143 ms | 4904 KB | Output is correct |
17 | Correct | 143 ms | 4860 KB | Output is correct |
18 | Correct | 142 ms | 4984 KB | Output is correct |