# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
241339 |
2020-06-24T04:22:10 Z |
arnold518 |
None (JOI16_ho_t5) |
C++14 |
|
163 ms |
15480 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e5;
struct Data
{
ll X, D, L;
};
int N, Q, S;
Data A[MAXN+10];
struct BIT
{
ll tree[MAXN+10];
void init() { memset(tree, 0, sizeof(tree)); }
void update(int i, ll k) { for(i=max(i, 1); i<=N; i+=(i&-i)) tree[i]+=k; }
ll query(int i) { ll ret=0; for(; i>0; i-=(i&-i)) ret+=tree[i]; return ret; }
}bitx, bity;
int main()
{
int i, j;
scanf("%d%d", &N, &Q);
for(i=1; i<=Q; i++) scanf("%lld%lld%lld", &A[i].X, &A[i].D, &A[i].L);
reverse(A+1, A+Q+1);
bitx.init(); bity.init();
bity.update(1, N);
for(i=2; i<=N; i++) bity.update(i, -1);
for(i=1; i<=N; i++) bitx.update(i, 1);
for(i=1; i<=Q; i++)
{
if(A[i].D==1)
{
int lo=0, hi=N+1;
while(lo+1<hi)
{
int mid=lo+hi>>1;
if(bitx.query(mid)<=A[i].X) lo=mid;
else hi=mid;
}
bity.update(N-lo+1, -2*A[i].L);
}
else
{
int lo=0, hi=N+1;
while(lo+1<hi)
{
int mid=lo+hi>>1;
if(bity.query(N-mid+1)>A[i].X) hi=mid;
else lo=mid;
}
bitx.update(hi, 2*A[i].L);
}
//for(j=1; j<=N; j++) printf("(%lld %lld) ", bitx.query(j), bity.query(N-j+1)); printf("\n");
}
for(i=1; i<=N; i++) printf("%lld\n", (bitx.query(i)-bity.query(N-i+1))/2);
}
Compilation message
2016_ho_t5.cpp: In function 'int main()':
2016_ho_t5.cpp:45:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid=lo+hi>>1;
~~^~~
2016_ho_t5.cpp:56:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid=lo+hi>>1;
~~^~~
2016_ho_t5.cpp:28:9: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
2016_ho_t5.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &N, &Q);
~~~~~^~~~~~~~~~~~~~~~
2016_ho_t5.cpp:31:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(i=1; i<=Q; i++) scanf("%lld%lld%lld", &A[i].X, &A[i].D, &A[i].L);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3456 KB |
Output is correct |
2 |
Correct |
6 ms |
3456 KB |
Output is correct |
3 |
Correct |
7 ms |
3456 KB |
Output is correct |
4 |
Correct |
6 ms |
3456 KB |
Output is correct |
5 |
Correct |
7 ms |
3456 KB |
Output is correct |
6 |
Correct |
7 ms |
3456 KB |
Output is correct |
7 |
Correct |
7 ms |
3456 KB |
Output is correct |
8 |
Correct |
7 ms |
3456 KB |
Output is correct |
9 |
Correct |
7 ms |
3456 KB |
Output is correct |
10 |
Correct |
6 ms |
3456 KB |
Output is correct |
11 |
Correct |
6 ms |
3456 KB |
Output is correct |
12 |
Correct |
6 ms |
3328 KB |
Output is correct |
13 |
Correct |
7 ms |
3456 KB |
Output is correct |
14 |
Correct |
7 ms |
3456 KB |
Output is correct |
15 |
Correct |
6 ms |
3456 KB |
Output is correct |
16 |
Correct |
6 ms |
3456 KB |
Output is correct |
17 |
Correct |
6 ms |
3456 KB |
Output is correct |
18 |
Correct |
7 ms |
3456 KB |
Output is correct |
19 |
Correct |
6 ms |
3456 KB |
Output is correct |
20 |
Correct |
7 ms |
3456 KB |
Output is correct |
21 |
Correct |
7 ms |
3456 KB |
Output is correct |
22 |
Correct |
7 ms |
3456 KB |
Output is correct |
23 |
Correct |
6 ms |
3456 KB |
Output is correct |
24 |
Correct |
6 ms |
3456 KB |
Output is correct |
25 |
Correct |
6 ms |
3456 KB |
Output is correct |
26 |
Correct |
6 ms |
3456 KB |
Output is correct |
27 |
Correct |
7 ms |
3456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3456 KB |
Output is correct |
2 |
Correct |
6 ms |
3456 KB |
Output is correct |
3 |
Correct |
7 ms |
3456 KB |
Output is correct |
4 |
Correct |
6 ms |
3456 KB |
Output is correct |
5 |
Correct |
7 ms |
3456 KB |
Output is correct |
6 |
Correct |
7 ms |
3456 KB |
Output is correct |
7 |
Correct |
7 ms |
3456 KB |
Output is correct |
8 |
Correct |
7 ms |
3456 KB |
Output is correct |
9 |
Correct |
7 ms |
3456 KB |
Output is correct |
10 |
Correct |
6 ms |
3456 KB |
Output is correct |
11 |
Correct |
6 ms |
3456 KB |
Output is correct |
12 |
Correct |
6 ms |
3328 KB |
Output is correct |
13 |
Correct |
7 ms |
3456 KB |
Output is correct |
14 |
Correct |
7 ms |
3456 KB |
Output is correct |
15 |
Correct |
6 ms |
3456 KB |
Output is correct |
16 |
Correct |
6 ms |
3456 KB |
Output is correct |
17 |
Correct |
6 ms |
3456 KB |
Output is correct |
18 |
Correct |
7 ms |
3456 KB |
Output is correct |
19 |
Correct |
6 ms |
3456 KB |
Output is correct |
20 |
Correct |
7 ms |
3456 KB |
Output is correct |
21 |
Correct |
7 ms |
3456 KB |
Output is correct |
22 |
Correct |
7 ms |
3456 KB |
Output is correct |
23 |
Correct |
6 ms |
3456 KB |
Output is correct |
24 |
Correct |
6 ms |
3456 KB |
Output is correct |
25 |
Correct |
6 ms |
3456 KB |
Output is correct |
26 |
Correct |
6 ms |
3456 KB |
Output is correct |
27 |
Correct |
7 ms |
3456 KB |
Output is correct |
28 |
Correct |
8 ms |
3584 KB |
Output is correct |
29 |
Correct |
9 ms |
3584 KB |
Output is correct |
30 |
Correct |
7 ms |
3584 KB |
Output is correct |
31 |
Correct |
9 ms |
3584 KB |
Output is correct |
32 |
Correct |
8 ms |
3576 KB |
Output is correct |
33 |
Correct |
8 ms |
3584 KB |
Output is correct |
34 |
Correct |
8 ms |
3584 KB |
Output is correct |
35 |
Correct |
8 ms |
3584 KB |
Output is correct |
36 |
Correct |
8 ms |
3584 KB |
Output is correct |
37 |
Correct |
8 ms |
3584 KB |
Output is correct |
38 |
Correct |
8 ms |
3584 KB |
Output is correct |
39 |
Correct |
9 ms |
3584 KB |
Output is correct |
40 |
Correct |
8 ms |
3584 KB |
Output is correct |
41 |
Correct |
8 ms |
3584 KB |
Output is correct |
42 |
Correct |
9 ms |
3584 KB |
Output is correct |
43 |
Correct |
8 ms |
3584 KB |
Output is correct |
44 |
Correct |
9 ms |
3584 KB |
Output is correct |
45 |
Correct |
8 ms |
3584 KB |
Output is correct |
46 |
Correct |
8 ms |
3584 KB |
Output is correct |
47 |
Correct |
9 ms |
3584 KB |
Output is correct |
48 |
Correct |
8 ms |
3712 KB |
Output is correct |
49 |
Correct |
8 ms |
3584 KB |
Output is correct |
50 |
Correct |
9 ms |
3584 KB |
Output is correct |
51 |
Correct |
8 ms |
3584 KB |
Output is correct |
52 |
Correct |
9 ms |
3584 KB |
Output is correct |
53 |
Correct |
9 ms |
3584 KB |
Output is correct |
54 |
Correct |
9 ms |
3712 KB |
Output is correct |
55 |
Correct |
8 ms |
3584 KB |
Output is correct |
56 |
Correct |
8 ms |
3584 KB |
Output is correct |
57 |
Correct |
8 ms |
3584 KB |
Output is correct |
58 |
Correct |
8 ms |
3584 KB |
Output is correct |
59 |
Correct |
8 ms |
3584 KB |
Output is correct |
60 |
Correct |
8 ms |
3584 KB |
Output is correct |
61 |
Correct |
8 ms |
3584 KB |
Output is correct |
62 |
Correct |
8 ms |
3584 KB |
Output is correct |
63 |
Correct |
8 ms |
3584 KB |
Output is correct |
64 |
Correct |
8 ms |
3584 KB |
Output is correct |
65 |
Correct |
8 ms |
3584 KB |
Output is correct |
66 |
Correct |
8 ms |
3584 KB |
Output is correct |
67 |
Correct |
9 ms |
3584 KB |
Output is correct |
68 |
Correct |
8 ms |
3584 KB |
Output is correct |
69 |
Correct |
8 ms |
3584 KB |
Output is correct |
70 |
Correct |
7 ms |
3456 KB |
Output is correct |
71 |
Correct |
7 ms |
3456 KB |
Output is correct |
72 |
Correct |
7 ms |
3456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3456 KB |
Output is correct |
2 |
Correct |
6 ms |
3456 KB |
Output is correct |
3 |
Correct |
7 ms |
3456 KB |
Output is correct |
4 |
Correct |
6 ms |
3456 KB |
Output is correct |
5 |
Correct |
7 ms |
3456 KB |
Output is correct |
6 |
Correct |
7 ms |
3456 KB |
Output is correct |
7 |
Correct |
7 ms |
3456 KB |
Output is correct |
8 |
Correct |
7 ms |
3456 KB |
Output is correct |
9 |
Correct |
7 ms |
3456 KB |
Output is correct |
10 |
Correct |
6 ms |
3456 KB |
Output is correct |
11 |
Correct |
6 ms |
3456 KB |
Output is correct |
12 |
Correct |
6 ms |
3328 KB |
Output is correct |
13 |
Correct |
7 ms |
3456 KB |
Output is correct |
14 |
Correct |
7 ms |
3456 KB |
Output is correct |
15 |
Correct |
6 ms |
3456 KB |
Output is correct |
16 |
Correct |
6 ms |
3456 KB |
Output is correct |
17 |
Correct |
6 ms |
3456 KB |
Output is correct |
18 |
Correct |
7 ms |
3456 KB |
Output is correct |
19 |
Correct |
6 ms |
3456 KB |
Output is correct |
20 |
Correct |
7 ms |
3456 KB |
Output is correct |
21 |
Correct |
7 ms |
3456 KB |
Output is correct |
22 |
Correct |
7 ms |
3456 KB |
Output is correct |
23 |
Correct |
6 ms |
3456 KB |
Output is correct |
24 |
Correct |
6 ms |
3456 KB |
Output is correct |
25 |
Correct |
6 ms |
3456 KB |
Output is correct |
26 |
Correct |
6 ms |
3456 KB |
Output is correct |
27 |
Correct |
7 ms |
3456 KB |
Output is correct |
28 |
Correct |
8 ms |
3584 KB |
Output is correct |
29 |
Correct |
9 ms |
3584 KB |
Output is correct |
30 |
Correct |
7 ms |
3584 KB |
Output is correct |
31 |
Correct |
9 ms |
3584 KB |
Output is correct |
32 |
Correct |
8 ms |
3576 KB |
Output is correct |
33 |
Correct |
8 ms |
3584 KB |
Output is correct |
34 |
Correct |
8 ms |
3584 KB |
Output is correct |
35 |
Correct |
8 ms |
3584 KB |
Output is correct |
36 |
Correct |
8 ms |
3584 KB |
Output is correct |
37 |
Correct |
8 ms |
3584 KB |
Output is correct |
38 |
Correct |
8 ms |
3584 KB |
Output is correct |
39 |
Correct |
9 ms |
3584 KB |
Output is correct |
40 |
Correct |
8 ms |
3584 KB |
Output is correct |
41 |
Correct |
8 ms |
3584 KB |
Output is correct |
42 |
Correct |
9 ms |
3584 KB |
Output is correct |
43 |
Correct |
8 ms |
3584 KB |
Output is correct |
44 |
Correct |
9 ms |
3584 KB |
Output is correct |
45 |
Correct |
8 ms |
3584 KB |
Output is correct |
46 |
Correct |
8 ms |
3584 KB |
Output is correct |
47 |
Correct |
9 ms |
3584 KB |
Output is correct |
48 |
Correct |
8 ms |
3712 KB |
Output is correct |
49 |
Correct |
8 ms |
3584 KB |
Output is correct |
50 |
Correct |
9 ms |
3584 KB |
Output is correct |
51 |
Correct |
8 ms |
3584 KB |
Output is correct |
52 |
Correct |
9 ms |
3584 KB |
Output is correct |
53 |
Correct |
9 ms |
3584 KB |
Output is correct |
54 |
Correct |
9 ms |
3712 KB |
Output is correct |
55 |
Correct |
8 ms |
3584 KB |
Output is correct |
56 |
Correct |
8 ms |
3584 KB |
Output is correct |
57 |
Correct |
8 ms |
3584 KB |
Output is correct |
58 |
Correct |
8 ms |
3584 KB |
Output is correct |
59 |
Correct |
8 ms |
3584 KB |
Output is correct |
60 |
Correct |
8 ms |
3584 KB |
Output is correct |
61 |
Correct |
8 ms |
3584 KB |
Output is correct |
62 |
Correct |
8 ms |
3584 KB |
Output is correct |
63 |
Correct |
8 ms |
3584 KB |
Output is correct |
64 |
Correct |
8 ms |
3584 KB |
Output is correct |
65 |
Correct |
8 ms |
3584 KB |
Output is correct |
66 |
Correct |
8 ms |
3584 KB |
Output is correct |
67 |
Correct |
9 ms |
3584 KB |
Output is correct |
68 |
Correct |
8 ms |
3584 KB |
Output is correct |
69 |
Correct |
8 ms |
3584 KB |
Output is correct |
70 |
Correct |
7 ms |
3456 KB |
Output is correct |
71 |
Correct |
7 ms |
3456 KB |
Output is correct |
72 |
Correct |
7 ms |
3456 KB |
Output is correct |
73 |
Correct |
160 ms |
11640 KB |
Output is correct |
74 |
Correct |
163 ms |
11512 KB |
Output is correct |
75 |
Correct |
162 ms |
11768 KB |
Output is correct |
76 |
Correct |
158 ms |
11768 KB |
Output is correct |
77 |
Correct |
162 ms |
11640 KB |
Output is correct |
78 |
Correct |
154 ms |
11680 KB |
Output is correct |
79 |
Correct |
155 ms |
11768 KB |
Output is correct |
80 |
Correct |
138 ms |
12152 KB |
Output is correct |
81 |
Correct |
132 ms |
12280 KB |
Output is correct |
82 |
Correct |
133 ms |
12408 KB |
Output is correct |
83 |
Correct |
140 ms |
13048 KB |
Output is correct |
84 |
Correct |
155 ms |
13212 KB |
Output is correct |
85 |
Correct |
136 ms |
13176 KB |
Output is correct |
86 |
Correct |
139 ms |
13688 KB |
Output is correct |
87 |
Correct |
143 ms |
14456 KB |
Output is correct |
88 |
Correct |
154 ms |
15480 KB |
Output is correct |
89 |
Correct |
154 ms |
15480 KB |
Output is correct |
90 |
Correct |
139 ms |
13944 KB |
Output is correct |
91 |
Correct |
118 ms |
10616 KB |
Output is correct |
92 |
Correct |
117 ms |
10872 KB |
Output is correct |
93 |
Correct |
160 ms |
14200 KB |
Output is correct |
94 |
Correct |
141 ms |
11512 KB |
Output is correct |
95 |
Correct |
157 ms |
13560 KB |
Output is correct |
96 |
Correct |
143 ms |
11512 KB |
Output is correct |
97 |
Correct |
142 ms |
12512 KB |
Output is correct |
98 |
Correct |
153 ms |
11408 KB |
Output is correct |
99 |
Correct |
156 ms |
13364 KB |
Output is correct |
100 |
Correct |
143 ms |
11384 KB |
Output is correct |
101 |
Correct |
145 ms |
12868 KB |
Output is correct |
102 |
Correct |
150 ms |
11512 KB |
Output is correct |
103 |
Correct |
155 ms |
13432 KB |
Output is correct |
104 |
Correct |
141 ms |
11512 KB |
Output is correct |
105 |
Correct |
136 ms |
13048 KB |
Output is correct |
106 |
Correct |
139 ms |
11512 KB |
Output is correct |
107 |
Correct |
142 ms |
13372 KB |
Output is correct |
108 |
Correct |
141 ms |
11388 KB |
Output is correct |
109 |
Correct |
131 ms |
12920 KB |
Output is correct |
110 |
Correct |
149 ms |
11640 KB |
Output is correct |
111 |
Correct |
155 ms |
14456 KB |
Output is correct |
112 |
Correct |
129 ms |
11640 KB |
Output is correct |
113 |
Correct |
156 ms |
14904 KB |
Output is correct |
114 |
Correct |
148 ms |
11640 KB |
Output is correct |
115 |
Correct |
140 ms |
12024 KB |
Output is correct |
116 |
Correct |
144 ms |
11640 KB |
Output is correct |
117 |
Correct |
155 ms |
14840 KB |
Output is correct |
118 |
Correct |
138 ms |
11640 KB |
Output is correct |
119 |
Correct |
42 ms |
5624 KB |
Output is correct |
120 |
Correct |
35 ms |
3832 KB |
Output is correct |