# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
397907 |
2021-05-03T11:20:49 Z |
qwerasdfzxcl |
None (JOI16_ho_t5) |
C++14 |
|
257 ms |
13596 KB |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct Seg{
ll lazy[400400];
int sz;
void update(int l, int r, ll val){
for(l += sz, r += sz;l<r;l>>=1, r>>=1){
if (l&1) lazy[l++] += val;
if (r&1) lazy[--r] += val;
}
}
ll query(int x){
ll ret = lazy[x+=sz];
for (x>>=1;x;x>>=1) ret += lazy[x];
return ret;
}
}tree1, tree2;
struct Query{
int x, d;
ll l;
}query[200200];
int main(){
int n, q;
scanf("%d %d", &n, &q);
for (int i=0;i<q;i++) scanf("%d %d %lld", &query[i].x, &query[i].d, &query[i].l);
tree1.sz = n, tree2.sz = n;
for (int i=q-1;i>=0;i--){
if (query[i].d==1){
int l = 0, r = n, idx=0;
while(l!=r){
int m = (l+r)/2;
ll tmp = tree1.query(m)*2-m;
if (tmp>-query[i].x){
idx = m+1;
l = m+1;
}
else r = m;
}
//printf("1 %d %d\n", i, idx);
tree2.update(0, idx, -query[i].l);
}
else{
int l = 0, r = n, idx = n;
while(l!=r){
int m = (l+r)/2;
ll tmp = tree2.query(m)*2+m;
if (tmp>=query[i].x){
idx = m;
r = m;
}
else l = m+1;
}
//printf("2 %d %d\n", i, idx);
tree1.update(idx, n, -query[i].l);
}
}
for (int i=0;i<n;i++){
ll ans = tree1.query(i) + tree2.query(i);
printf("%lld\n", -ans);
}
return 0;
}
Compilation message
2016_ho_t5.cpp: In function 'int main()':
2016_ho_t5.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
27 | scanf("%d %d", &n, &q);
| ~~~~~^~~~~~~~~~~~~~~~~
2016_ho_t5.cpp:28:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
28 | for (int i=0;i<q;i++) scanf("%d %d %lld", &query[i].x, &query[i].d, &query[i].l);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
308 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
308 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
320 KB |
Output is correct |
31 |
Correct |
3 ms |
432 KB |
Output is correct |
32 |
Correct |
2 ms |
324 KB |
Output is correct |
33 |
Correct |
3 ms |
460 KB |
Output is correct |
34 |
Correct |
3 ms |
448 KB |
Output is correct |
35 |
Correct |
3 ms |
460 KB |
Output is correct |
36 |
Correct |
4 ms |
460 KB |
Output is correct |
37 |
Correct |
3 ms |
460 KB |
Output is correct |
38 |
Correct |
2 ms |
332 KB |
Output is correct |
39 |
Correct |
2 ms |
460 KB |
Output is correct |
40 |
Correct |
2 ms |
460 KB |
Output is correct |
41 |
Correct |
3 ms |
460 KB |
Output is correct |
42 |
Correct |
3 ms |
464 KB |
Output is correct |
43 |
Correct |
3 ms |
460 KB |
Output is correct |
44 |
Correct |
3 ms |
460 KB |
Output is correct |
45 |
Correct |
3 ms |
460 KB |
Output is correct |
46 |
Correct |
3 ms |
332 KB |
Output is correct |
47 |
Correct |
3 ms |
460 KB |
Output is correct |
48 |
Correct |
3 ms |
460 KB |
Output is correct |
49 |
Correct |
3 ms |
460 KB |
Output is correct |
50 |
Correct |
3 ms |
356 KB |
Output is correct |
51 |
Correct |
3 ms |
364 KB |
Output is correct |
52 |
Correct |
3 ms |
460 KB |
Output is correct |
53 |
Correct |
3 ms |
488 KB |
Output is correct |
54 |
Correct |
3 ms |
448 KB |
Output is correct |
55 |
Correct |
4 ms |
444 KB |
Output is correct |
56 |
Correct |
3 ms |
460 KB |
Output is correct |
57 |
Correct |
3 ms |
460 KB |
Output is correct |
58 |
Correct |
3 ms |
460 KB |
Output is correct |
59 |
Correct |
3 ms |
460 KB |
Output is correct |
60 |
Correct |
3 ms |
460 KB |
Output is correct |
61 |
Correct |
3 ms |
460 KB |
Output is correct |
62 |
Correct |
2 ms |
440 KB |
Output is correct |
63 |
Correct |
3 ms |
444 KB |
Output is correct |
64 |
Correct |
2 ms |
332 KB |
Output is correct |
65 |
Correct |
2 ms |
332 KB |
Output is correct |
66 |
Correct |
3 ms |
368 KB |
Output is correct |
67 |
Correct |
2 ms |
332 KB |
Output is correct |
68 |
Correct |
3 ms |
460 KB |
Output is correct |
69 |
Correct |
2 ms |
332 KB |
Output is correct |
70 |
Correct |
1 ms |
332 KB |
Output is correct |
71 |
Correct |
1 ms |
332 KB |
Output is correct |
72 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
308 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
320 KB |
Output is correct |
31 |
Correct |
3 ms |
432 KB |
Output is correct |
32 |
Correct |
2 ms |
324 KB |
Output is correct |
33 |
Correct |
3 ms |
460 KB |
Output is correct |
34 |
Correct |
3 ms |
448 KB |
Output is correct |
35 |
Correct |
3 ms |
460 KB |
Output is correct |
36 |
Correct |
4 ms |
460 KB |
Output is correct |
37 |
Correct |
3 ms |
460 KB |
Output is correct |
38 |
Correct |
2 ms |
332 KB |
Output is correct |
39 |
Correct |
2 ms |
460 KB |
Output is correct |
40 |
Correct |
2 ms |
460 KB |
Output is correct |
41 |
Correct |
3 ms |
460 KB |
Output is correct |
42 |
Correct |
3 ms |
464 KB |
Output is correct |
43 |
Correct |
3 ms |
460 KB |
Output is correct |
44 |
Correct |
3 ms |
460 KB |
Output is correct |
45 |
Correct |
3 ms |
460 KB |
Output is correct |
46 |
Correct |
3 ms |
332 KB |
Output is correct |
47 |
Correct |
3 ms |
460 KB |
Output is correct |
48 |
Correct |
3 ms |
460 KB |
Output is correct |
49 |
Correct |
3 ms |
460 KB |
Output is correct |
50 |
Correct |
3 ms |
356 KB |
Output is correct |
51 |
Correct |
3 ms |
364 KB |
Output is correct |
52 |
Correct |
3 ms |
460 KB |
Output is correct |
53 |
Correct |
3 ms |
488 KB |
Output is correct |
54 |
Correct |
3 ms |
448 KB |
Output is correct |
55 |
Correct |
4 ms |
444 KB |
Output is correct |
56 |
Correct |
3 ms |
460 KB |
Output is correct |
57 |
Correct |
3 ms |
460 KB |
Output is correct |
58 |
Correct |
3 ms |
460 KB |
Output is correct |
59 |
Correct |
3 ms |
460 KB |
Output is correct |
60 |
Correct |
3 ms |
460 KB |
Output is correct |
61 |
Correct |
3 ms |
460 KB |
Output is correct |
62 |
Correct |
2 ms |
440 KB |
Output is correct |
63 |
Correct |
3 ms |
444 KB |
Output is correct |
64 |
Correct |
2 ms |
332 KB |
Output is correct |
65 |
Correct |
2 ms |
332 KB |
Output is correct |
66 |
Correct |
3 ms |
368 KB |
Output is correct |
67 |
Correct |
2 ms |
332 KB |
Output is correct |
68 |
Correct |
3 ms |
460 KB |
Output is correct |
69 |
Correct |
2 ms |
332 KB |
Output is correct |
70 |
Correct |
1 ms |
332 KB |
Output is correct |
71 |
Correct |
1 ms |
332 KB |
Output is correct |
72 |
Correct |
1 ms |
332 KB |
Output is correct |
73 |
Correct |
211 ms |
12948 KB |
Output is correct |
74 |
Correct |
257 ms |
13100 KB |
Output is correct |
75 |
Correct |
207 ms |
13132 KB |
Output is correct |
76 |
Correct |
211 ms |
13096 KB |
Output is correct |
77 |
Correct |
202 ms |
13180 KB |
Output is correct |
78 |
Correct |
194 ms |
13120 KB |
Output is correct |
79 |
Correct |
201 ms |
12952 KB |
Output is correct |
80 |
Correct |
174 ms |
13508 KB |
Output is correct |
81 |
Correct |
160 ms |
13596 KB |
Output is correct |
82 |
Correct |
180 ms |
13124 KB |
Output is correct |
83 |
Correct |
164 ms |
8972 KB |
Output is correct |
84 |
Correct |
181 ms |
8752 KB |
Output is correct |
85 |
Correct |
159 ms |
8728 KB |
Output is correct |
86 |
Correct |
163 ms |
9432 KB |
Output is correct |
87 |
Correct |
166 ms |
9692 KB |
Output is correct |
88 |
Correct |
180 ms |
10944 KB |
Output is correct |
89 |
Correct |
175 ms |
10912 KB |
Output is correct |
90 |
Correct |
157 ms |
9196 KB |
Output is correct |
91 |
Correct |
146 ms |
5900 KB |
Output is correct |
92 |
Correct |
148 ms |
6060 KB |
Output is correct |
93 |
Correct |
222 ms |
12564 KB |
Output is correct |
94 |
Correct |
186 ms |
9792 KB |
Output is correct |
95 |
Correct |
183 ms |
11924 KB |
Output is correct |
96 |
Correct |
177 ms |
9808 KB |
Output is correct |
97 |
Correct |
186 ms |
11740 KB |
Output is correct |
98 |
Correct |
183 ms |
12484 KB |
Output is correct |
99 |
Correct |
193 ms |
11692 KB |
Output is correct |
100 |
Correct |
229 ms |
9760 KB |
Output is correct |
101 |
Correct |
187 ms |
9924 KB |
Output is correct |
102 |
Correct |
185 ms |
11244 KB |
Output is correct |
103 |
Correct |
189 ms |
11876 KB |
Output is correct |
104 |
Correct |
180 ms |
9808 KB |
Output is correct |
105 |
Correct |
161 ms |
9884 KB |
Output is correct |
106 |
Correct |
179 ms |
8884 KB |
Output is correct |
107 |
Correct |
175 ms |
11580 KB |
Output is correct |
108 |
Correct |
212 ms |
11348 KB |
Output is correct |
109 |
Correct |
153 ms |
8116 KB |
Output is correct |
110 |
Correct |
151 ms |
6912 KB |
Output is correct |
111 |
Correct |
217 ms |
9860 KB |
Output is correct |
112 |
Correct |
157 ms |
6944 KB |
Output is correct |
113 |
Correct |
177 ms |
10184 KB |
Output is correct |
114 |
Correct |
161 ms |
7068 KB |
Output is correct |
115 |
Correct |
176 ms |
7276 KB |
Output is correct |
116 |
Correct |
164 ms |
6996 KB |
Output is correct |
117 |
Correct |
173 ms |
10136 KB |
Output is correct |
118 |
Correct |
159 ms |
6860 KB |
Output is correct |
119 |
Correct |
39 ms |
2500 KB |
Output is correct |
120 |
Correct |
30 ms |
588 KB |
Output is correct |