# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
125636 |
2019-07-06T06:19:37 Z |
윤교준(#3070) |
None (JOI16_ho_t5) |
C++14 |
|
159 ms |
13944 KB |
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define upmin(a,b) (a)=min((a),(b))
#define rb(x) ((x)&(-(x)))
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<ll, int> pli;
const int MAXN = 200055;
const int MAXQ = 200055;
struct BIT {
ll d[MAXN];
void upd(int x, ll r) {
for(x += 5; x < MAXN; x += rb(x))
d[x] += r;
}
ll get(int x) {
ll r = 0; for(x += 5; x; x -= rb(x))
r += d[x];
return r;
}
} bitX, bitY;
ll A[MAXQ], B[MAXQ];
bitset<MAXQ> C;
ll PX, PY;
int N, Q;
ll getX(int i) { return PX + bitX.get(i); }
ll getY(int i) { return PY - bitY.get(i); }
int main() {
ios::sync_with_stdio(false);
cin >> N >> Q;
for(int i = 1; i <= Q; i++) {
int c; cin >> A[i] >> c >> B[i];
C[i] = 2 == c;
}
for(int i = 1; i < N; i++) {
bitX.upd(i, 1);
bitY.upd(i, 1);
}
for(int qi = Q; qi; qi--) {
B[qi] <<= 1;
if(!C[qi]) {
A[qi] = -A[qi] + 1;
if(PY < A[qi]) continue;
int s = 0, e = N-1; for(int m; s < e;) {
m = (s+e+1) >> 1;
if(getY(m) >= A[qi]) s = m;
else e = m-1;
}
if(s+1 < N) bitX.upd(s+1, B[qi]);
PX -= B[qi];
} else {
if(getX(N-1) < A[qi]) continue;
int s = 0, e = N-1; for(int m; s < e;) {
m = (s+e) >> 1;
if(getX(m) >= A[qi]) e = m;
else s = m+1;
}
if(s) bitY.upd(s, B[qi]);
if(PX >= A[qi]) PY -= B[qi];
}
}
for(int i = 0; i < N; i++)
printf("%lld\n", (-getX(i)-getY(i)) >> 1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
380 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
504 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
504 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
504 KB |
Output is correct |
24 |
Correct |
2 ms |
504 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
504 KB |
Output is correct |
27 |
Correct |
2 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
380 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
504 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
504 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
504 KB |
Output is correct |
24 |
Correct |
2 ms |
504 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
504 KB |
Output is correct |
27 |
Correct |
2 ms |
504 KB |
Output is correct |
28 |
Correct |
4 ms |
504 KB |
Output is correct |
29 |
Correct |
4 ms |
504 KB |
Output is correct |
30 |
Correct |
4 ms |
504 KB |
Output is correct |
31 |
Correct |
4 ms |
476 KB |
Output is correct |
32 |
Correct |
3 ms |
504 KB |
Output is correct |
33 |
Correct |
4 ms |
504 KB |
Output is correct |
34 |
Correct |
4 ms |
504 KB |
Output is correct |
35 |
Correct |
4 ms |
504 KB |
Output is correct |
36 |
Correct |
4 ms |
504 KB |
Output is correct |
37 |
Correct |
4 ms |
508 KB |
Output is correct |
38 |
Correct |
4 ms |
504 KB |
Output is correct |
39 |
Correct |
4 ms |
504 KB |
Output is correct |
40 |
Correct |
4 ms |
504 KB |
Output is correct |
41 |
Correct |
4 ms |
504 KB |
Output is correct |
42 |
Correct |
4 ms |
504 KB |
Output is correct |
43 |
Correct |
4 ms |
504 KB |
Output is correct |
44 |
Correct |
4 ms |
632 KB |
Output is correct |
45 |
Correct |
4 ms |
504 KB |
Output is correct |
46 |
Correct |
4 ms |
632 KB |
Output is correct |
47 |
Correct |
4 ms |
504 KB |
Output is correct |
48 |
Correct |
4 ms |
504 KB |
Output is correct |
49 |
Correct |
4 ms |
508 KB |
Output is correct |
50 |
Correct |
4 ms |
504 KB |
Output is correct |
51 |
Correct |
4 ms |
504 KB |
Output is correct |
52 |
Correct |
4 ms |
632 KB |
Output is correct |
53 |
Correct |
4 ms |
504 KB |
Output is correct |
54 |
Correct |
4 ms |
508 KB |
Output is correct |
55 |
Correct |
4 ms |
504 KB |
Output is correct |
56 |
Correct |
4 ms |
504 KB |
Output is correct |
57 |
Correct |
4 ms |
504 KB |
Output is correct |
58 |
Correct |
4 ms |
504 KB |
Output is correct |
59 |
Correct |
4 ms |
504 KB |
Output is correct |
60 |
Correct |
4 ms |
504 KB |
Output is correct |
61 |
Correct |
4 ms |
504 KB |
Output is correct |
62 |
Correct |
4 ms |
504 KB |
Output is correct |
63 |
Correct |
4 ms |
504 KB |
Output is correct |
64 |
Correct |
4 ms |
504 KB |
Output is correct |
65 |
Correct |
4 ms |
504 KB |
Output is correct |
66 |
Correct |
4 ms |
504 KB |
Output is correct |
67 |
Correct |
4 ms |
504 KB |
Output is correct |
68 |
Correct |
4 ms |
508 KB |
Output is correct |
69 |
Correct |
4 ms |
504 KB |
Output is correct |
70 |
Correct |
3 ms |
508 KB |
Output is correct |
71 |
Correct |
3 ms |
504 KB |
Output is correct |
72 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
380 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
504 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
504 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
504 KB |
Output is correct |
24 |
Correct |
2 ms |
504 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
504 KB |
Output is correct |
27 |
Correct |
2 ms |
504 KB |
Output is correct |
28 |
Correct |
4 ms |
504 KB |
Output is correct |
29 |
Correct |
4 ms |
504 KB |
Output is correct |
30 |
Correct |
4 ms |
504 KB |
Output is correct |
31 |
Correct |
4 ms |
476 KB |
Output is correct |
32 |
Correct |
3 ms |
504 KB |
Output is correct |
33 |
Correct |
4 ms |
504 KB |
Output is correct |
34 |
Correct |
4 ms |
504 KB |
Output is correct |
35 |
Correct |
4 ms |
504 KB |
Output is correct |
36 |
Correct |
4 ms |
504 KB |
Output is correct |
37 |
Correct |
4 ms |
508 KB |
Output is correct |
38 |
Correct |
4 ms |
504 KB |
Output is correct |
39 |
Correct |
4 ms |
504 KB |
Output is correct |
40 |
Correct |
4 ms |
504 KB |
Output is correct |
41 |
Correct |
4 ms |
504 KB |
Output is correct |
42 |
Correct |
4 ms |
504 KB |
Output is correct |
43 |
Correct |
4 ms |
504 KB |
Output is correct |
44 |
Correct |
4 ms |
632 KB |
Output is correct |
45 |
Correct |
4 ms |
504 KB |
Output is correct |
46 |
Correct |
4 ms |
632 KB |
Output is correct |
47 |
Correct |
4 ms |
504 KB |
Output is correct |
48 |
Correct |
4 ms |
504 KB |
Output is correct |
49 |
Correct |
4 ms |
508 KB |
Output is correct |
50 |
Correct |
4 ms |
504 KB |
Output is correct |
51 |
Correct |
4 ms |
504 KB |
Output is correct |
52 |
Correct |
4 ms |
632 KB |
Output is correct |
53 |
Correct |
4 ms |
504 KB |
Output is correct |
54 |
Correct |
4 ms |
508 KB |
Output is correct |
55 |
Correct |
4 ms |
504 KB |
Output is correct |
56 |
Correct |
4 ms |
504 KB |
Output is correct |
57 |
Correct |
4 ms |
504 KB |
Output is correct |
58 |
Correct |
4 ms |
504 KB |
Output is correct |
59 |
Correct |
4 ms |
504 KB |
Output is correct |
60 |
Correct |
4 ms |
504 KB |
Output is correct |
61 |
Correct |
4 ms |
504 KB |
Output is correct |
62 |
Correct |
4 ms |
504 KB |
Output is correct |
63 |
Correct |
4 ms |
504 KB |
Output is correct |
64 |
Correct |
4 ms |
504 KB |
Output is correct |
65 |
Correct |
4 ms |
504 KB |
Output is correct |
66 |
Correct |
4 ms |
504 KB |
Output is correct |
67 |
Correct |
4 ms |
504 KB |
Output is correct |
68 |
Correct |
4 ms |
508 KB |
Output is correct |
69 |
Correct |
4 ms |
504 KB |
Output is correct |
70 |
Correct |
3 ms |
508 KB |
Output is correct |
71 |
Correct |
3 ms |
504 KB |
Output is correct |
72 |
Correct |
3 ms |
504 KB |
Output is correct |
73 |
Correct |
151 ms |
7960 KB |
Output is correct |
74 |
Correct |
155 ms |
9976 KB |
Output is correct |
75 |
Correct |
151 ms |
10232 KB |
Output is correct |
76 |
Correct |
150 ms |
10156 KB |
Output is correct |
77 |
Correct |
150 ms |
10232 KB |
Output is correct |
78 |
Correct |
150 ms |
10092 KB |
Output is correct |
79 |
Correct |
159 ms |
10360 KB |
Output is correct |
80 |
Correct |
126 ms |
10488 KB |
Output is correct |
81 |
Correct |
117 ms |
10860 KB |
Output is correct |
82 |
Correct |
114 ms |
10844 KB |
Output is correct |
83 |
Correct |
121 ms |
11524 KB |
Output is correct |
84 |
Correct |
121 ms |
11640 KB |
Output is correct |
85 |
Correct |
120 ms |
11640 KB |
Output is correct |
86 |
Correct |
118 ms |
12156 KB |
Output is correct |
87 |
Correct |
120 ms |
12796 KB |
Output is correct |
88 |
Correct |
133 ms |
13944 KB |
Output is correct |
89 |
Correct |
133 ms |
13944 KB |
Output is correct |
90 |
Correct |
132 ms |
12612 KB |
Output is correct |
91 |
Correct |
102 ms |
9080 KB |
Output is correct |
92 |
Correct |
106 ms |
9336 KB |
Output is correct |
93 |
Correct |
151 ms |
12664 KB |
Output is correct |
94 |
Correct |
132 ms |
9976 KB |
Output is correct |
95 |
Correct |
145 ms |
12024 KB |
Output is correct |
96 |
Correct |
131 ms |
9976 KB |
Output is correct |
97 |
Correct |
140 ms |
11128 KB |
Output is correct |
98 |
Correct |
135 ms |
9868 KB |
Output is correct |
99 |
Correct |
151 ms |
11768 KB |
Output is correct |
100 |
Correct |
134 ms |
9976 KB |
Output is correct |
101 |
Correct |
138 ms |
11256 KB |
Output is correct |
102 |
Correct |
136 ms |
9976 KB |
Output is correct |
103 |
Correct |
144 ms |
11800 KB |
Output is correct |
104 |
Correct |
130 ms |
9804 KB |
Output is correct |
105 |
Correct |
133 ms |
11584 KB |
Output is correct |
106 |
Correct |
126 ms |
10132 KB |
Output is correct |
107 |
Correct |
129 ms |
11768 KB |
Output is correct |
108 |
Correct |
135 ms |
9876 KB |
Output is correct |
109 |
Correct |
134 ms |
11384 KB |
Output is correct |
110 |
Correct |
125 ms |
10104 KB |
Output is correct |
111 |
Correct |
149 ms |
12920 KB |
Output is correct |
112 |
Correct |
128 ms |
10232 KB |
Output is correct |
113 |
Correct |
152 ms |
13388 KB |
Output is correct |
114 |
Correct |
131 ms |
10104 KB |
Output is correct |
115 |
Correct |
134 ms |
10488 KB |
Output is correct |
116 |
Correct |
136 ms |
10136 KB |
Output is correct |
117 |
Correct |
152 ms |
13404 KB |
Output is correct |
118 |
Correct |
131 ms |
10232 KB |
Output is correct |
119 |
Correct |
38 ms |
5624 KB |
Output is correct |
120 |
Correct |
32 ms |
3832 KB |
Output is correct |