# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55358 | 2018-07-07T05:20:39 Z | 김세빈(#1545) | Employment (JOI16_employment) | C++11 | 305 ms | 50860 KB |
#include <bits/stdc++.h> using namespace std; struct node{ int l, r, v; node() { l = r = v = 0; } }; node T[2020202]; int K[202020], A[202020]; int n, m, t; int update(int p) { int a = K[p]; if(A[p] >= A[p-1] && A[p] > A[p+1]) K[p] = 1; else if(A[p] < A[p-1] && A[p] <= A[p+1]) K[p] = -1; else K[p] = 0; return K[p] - a; } void insert(int p, int s, int e, int v, int c) { T[p].v += c; if(s == e) return; if(v <= (s+e>>1)){ if(!T[p].l) T[p].l = ++t; insert(T[p].l, s, s+e>>1, v, c); } else{ if(!T[p].r) T[p].r = ++t; insert(T[p].r, (s+e>>1)+1, e, v, c); } } int get_sum(int p, int s, int e, int l, int r) { if(!p || e < l || r < s) return 0; if(l <= s && e <= r) return T[p].v; return get_sum(T[p].l, s, s+e>>1, l, r) + get_sum(T[p].r, (s+e>>1)+1, e, l, r); } int main() { int i, k, a, b; scanf("%d%d", &n, &m); A[0] = A[n+1] = -1e9; t = 1; for(i=1;i<=n;i++){ scanf("%d", A+i); } for(i=1;i<=n;i++){ insert(1, 1, 1e9, A[i], update(i)); } for(i=0;i<m;i++){ scanf("%d", &a); if(a == 1){ scanf("%d", &a); printf("%d\n", get_sum(1, 1, 1e9, a, 1e9)); } else{ scanf("%d", &k); insert(1, 1, 1e9, A[k], -K[k]); K[k] = 0; scanf("%d", A+k); insert(1, 1, 1e9, A[k], update(k)); if(k > 1) insert(1, 1, 1e9, A[k-1], update(k-1)); if(k < n) insert(1, 1, 1e9, A[k+1], update(k+1)); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 24056 KB | Output is correct |
2 | Correct | 19 ms | 24056 KB | Output is correct |
3 | Correct | 23 ms | 24268 KB | Output is correct |
4 | Correct | 21 ms | 24268 KB | Output is correct |
5 | Correct | 21 ms | 24268 KB | Output is correct |
6 | Correct | 21 ms | 24268 KB | Output is correct |
7 | Correct | 22 ms | 24268 KB | Output is correct |
8 | Correct | 22 ms | 24316 KB | Output is correct |
9 | Correct | 22 ms | 24316 KB | Output is correct |
10 | Correct | 25 ms | 24316 KB | Output is correct |
11 | Correct | 26 ms | 24316 KB | Output is correct |
12 | Correct | 23 ms | 24316 KB | Output is correct |
13 | Correct | 22 ms | 24316 KB | Output is correct |
14 | Correct | 23 ms | 24316 KB | Output is correct |
15 | Correct | 24 ms | 24316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 24316 KB | Output is correct |
2 | Correct | 23 ms | 24316 KB | Output is correct |
3 | Correct | 23 ms | 24316 KB | Output is correct |
4 | Correct | 44 ms | 24548 KB | Output is correct |
5 | Correct | 67 ms | 24840 KB | Output is correct |
6 | Correct | 79 ms | 24972 KB | Output is correct |
7 | Correct | 128 ms | 25368 KB | Output is correct |
8 | Correct | 198 ms | 25648 KB | Output is correct |
9 | Correct | 305 ms | 26464 KB | Output is correct |
10 | Runtime error | 157 ms | 50860 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 24056 KB | Output is correct |
2 | Correct | 19 ms | 24056 KB | Output is correct |
3 | Correct | 23 ms | 24268 KB | Output is correct |
4 | Correct | 21 ms | 24268 KB | Output is correct |
5 | Correct | 21 ms | 24268 KB | Output is correct |
6 | Correct | 21 ms | 24268 KB | Output is correct |
7 | Correct | 22 ms | 24268 KB | Output is correct |
8 | Correct | 22 ms | 24316 KB | Output is correct |
9 | Correct | 22 ms | 24316 KB | Output is correct |
10 | Correct | 25 ms | 24316 KB | Output is correct |
11 | Correct | 26 ms | 24316 KB | Output is correct |
12 | Correct | 23 ms | 24316 KB | Output is correct |
13 | Correct | 22 ms | 24316 KB | Output is correct |
14 | Correct | 23 ms | 24316 KB | Output is correct |
15 | Correct | 24 ms | 24316 KB | Output is correct |
16 | Correct | 23 ms | 24316 KB | Output is correct |
17 | Correct | 23 ms | 24316 KB | Output is correct |
18 | Correct | 23 ms | 24316 KB | Output is correct |
19 | Correct | 44 ms | 24548 KB | Output is correct |
20 | Correct | 67 ms | 24840 KB | Output is correct |
21 | Correct | 79 ms | 24972 KB | Output is correct |
22 | Correct | 128 ms | 25368 KB | Output is correct |
23 | Correct | 198 ms | 25648 KB | Output is correct |
24 | Correct | 305 ms | 26464 KB | Output is correct |
25 | Runtime error | 157 ms | 50860 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
26 | Halted | 0 ms | 0 KB | - |