# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
114348 | 2019-06-01T03:14:56 Z | onjo0127 | Employment (JOI16_employment) | C++11 | 242 ms | 13188 KB |
#include <bits/stdc++.h> using namespace std; struct query { int ty, a, b; } B[200009]; vector<int> S; int A[200009], C[200009], F[400009]; int f(int x) { return (int)S.size() - (lower_bound(S.begin(), S.end(), x) - S.begin()); } void upd(int x, int y) { for(int i=x; i<=(int)S.size(); i+=(i&-i)) F[i] += y; } int get(int x) {int s = 0; for(int i=x; i>=1; i-=(i&-i)) s += F[i]; return s; } void update(int id, int nw) { upd(A[id], -C[id]); A[id] = nw; if(A[id-1] <= A[id] && A[id+1] < A[id]) C[id] = -1; else if(A[id-1] > A[id] && A[id+1] >= A[id]) C[id] = +1; else C[id] = 0; upd(A[id], C[id]); } int main() { int N, M; scanf("%d%d",&N,&M); for(int i=1; i<=N; i++) { scanf("%d",&A[i]); S.push_back(A[i]); } A[0] = A[N+1] = 1e9; for(int i=0; i<M; i++) { int t, a, b = -1; scanf("%d",&t); if(t == 1) { scanf("%d",&a); S.push_back(a); } else { scanf("%d%d",&a,&b); S.push_back(b); } B[i] = {t, a, b}; } sort(S.begin(), S.end()); S.resize(unique(S.begin(), S.end()) - S.begin()); for(int i=1; i<=N; i++) A[i] = f(A[i]); for(int i=0; i<M; i++) { if(B[i].ty == 1) B[i].a = f(B[i].a); else B[i].b = f(B[i].b); } for(int i=1; i<=N; i++) { if(A[i-1] <= A[i] && A[i+1] < A[i]) C[i] = -1; else if(A[i-1] > A[i] && A[i+1] >= A[i]) C[i] = +1; else C[i] = 0; upd(A[i], C[i]); } for(int i=0; i<M; i++) { if(B[i].ty == 1) printf("%d\n", get(B[i].a)); else { int id = B[i].a, nw = B[i].b; update(id, nw); if(id != 1) update(id-1, A[id-1]); if(id != N) update(id+1, A[id+1]); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 412 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 512 KB | Output is correct |
12 | Correct | 4 ms | 512 KB | Output is correct |
13 | Correct | 4 ms | 512 KB | Output is correct |
14 | Correct | 4 ms | 512 KB | Output is correct |
15 | Correct | 4 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 512 KB | Output is correct |
2 | Correct | 4 ms | 512 KB | Output is correct |
3 | Correct | 4 ms | 512 KB | Output is correct |
4 | Correct | 16 ms | 1536 KB | Output is correct |
5 | Correct | 29 ms | 2428 KB | Output is correct |
6 | Correct | 46 ms | 3604 KB | Output is correct |
7 | Correct | 74 ms | 5148 KB | Output is correct |
8 | Correct | 90 ms | 6376 KB | Output is correct |
9 | Correct | 157 ms | 10340 KB | Output is correct |
10 | Correct | 144 ms | 9032 KB | Output is correct |
11 | Correct | 190 ms | 11660 KB | Output is correct |
12 | Correct | 217 ms | 12812 KB | Output is correct |
13 | Correct | 212 ms | 12796 KB | Output is correct |
14 | Correct | 195 ms | 12644 KB | Output is correct |
15 | Correct | 211 ms | 12716 KB | Output is correct |
16 | Correct | 206 ms | 13028 KB | Output is correct |
17 | Correct | 206 ms | 12872 KB | Output is correct |
18 | Correct | 215 ms | 12900 KB | Output is correct |
19 | Correct | 209 ms | 13012 KB | Output is correct |
20 | Correct | 208 ms | 13156 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 412 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 512 KB | Output is correct |
12 | Correct | 4 ms | 512 KB | Output is correct |
13 | Correct | 4 ms | 512 KB | Output is correct |
14 | Correct | 4 ms | 512 KB | Output is correct |
15 | Correct | 4 ms | 512 KB | Output is correct |
16 | Correct | 4 ms | 512 KB | Output is correct |
17 | Correct | 4 ms | 512 KB | Output is correct |
18 | Correct | 4 ms | 512 KB | Output is correct |
19 | Correct | 16 ms | 1536 KB | Output is correct |
20 | Correct | 29 ms | 2428 KB | Output is correct |
21 | Correct | 46 ms | 3604 KB | Output is correct |
22 | Correct | 74 ms | 5148 KB | Output is correct |
23 | Correct | 90 ms | 6376 KB | Output is correct |
24 | Correct | 157 ms | 10340 KB | Output is correct |
25 | Correct | 144 ms | 9032 KB | Output is correct |
26 | Correct | 190 ms | 11660 KB | Output is correct |
27 | Correct | 217 ms | 12812 KB | Output is correct |
28 | Correct | 212 ms | 12796 KB | Output is correct |
29 | Correct | 195 ms | 12644 KB | Output is correct |
30 | Correct | 211 ms | 12716 KB | Output is correct |
31 | Correct | 206 ms | 13028 KB | Output is correct |
32 | Correct | 206 ms | 12872 KB | Output is correct |
33 | Correct | 215 ms | 12900 KB | Output is correct |
34 | Correct | 209 ms | 13012 KB | Output is correct |
35 | Correct | 208 ms | 13156 KB | Output is correct |
36 | Correct | 3 ms | 512 KB | Output is correct |
37 | Correct | 4 ms | 512 KB | Output is correct |
38 | Correct | 4 ms | 512 KB | Output is correct |
39 | Correct | 16 ms | 1412 KB | Output is correct |
40 | Correct | 29 ms | 2276 KB | Output is correct |
41 | Correct | 52 ms | 3516 KB | Output is correct |
42 | Correct | 73 ms | 4716 KB | Output is correct |
43 | Correct | 100 ms | 6312 KB | Output is correct |
44 | Correct | 185 ms | 10724 KB | Output is correct |
45 | Correct | 150 ms | 8916 KB | Output is correct |
46 | Correct | 169 ms | 9836 KB | Output is correct |
47 | Correct | 224 ms | 12676 KB | Output is correct |
48 | Correct | 231 ms | 12808 KB | Output is correct |
49 | Correct | 235 ms | 12972 KB | Output is correct |
50 | Correct | 223 ms | 12644 KB | Output is correct |
51 | Correct | 237 ms | 12900 KB | Output is correct |
52 | Correct | 238 ms | 13188 KB | Output is correct |
53 | Correct | 233 ms | 12952 KB | Output is correct |
54 | Correct | 242 ms | 13028 KB | Output is correct |
55 | Correct | 230 ms | 13028 KB | Output is correct |