# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
533713 |
2022-03-07T03:41:34 Z |
rk42745417 |
None (JOI16_ho_t5) |
C++17 |
|
95 ms |
13036 KB |
#include <bits/stdc++.h>
using namespace std;
#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const ll LINF = ll(4e18) + ll(2e15);
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
static int LamyIsCute = []() {
EmiliaMyWife
return 48763;
}();
const int N = 2e5 + 25;
struct fenwicktree {
ll arr[N];
void edt(int p, ll v) {
for(; p < N; p += p & -p)
arr[p] += v;
}
ll que(int p) {
ll res = 0;
for(; p; p -= p & -p)
res += arr[p];
return res;
}
int fnd(ll k) {
int p = 0;
ll res = 0;
for(int i = 1 << 19; i; i >>= 1)
if(p + i < N && res + arr[p + i] < k)
res += arr[p |= i];
return p + 1;
}
} x, y;
signed main() {
int n, q;
cin >> n >> q;
vector<tuple<int, int, int>> que(q);
for(auto &[x, d, l] : que)
cin >> x >> d >> l;
reverse(que.begin(), que.end());
for(int i = 1; i <= n; i++)
x.edt(i, 1), y.edt(i, 1);
x.edt(n + 1, LINF);
y.edt(n + 1, LINF);
for(const auto &[s, d, l] : que) {
if(d == 1) {
int it = x.fnd(s + 1);
y.edt(1, -l * 2);
y.edt(it, l * 2);
}
else {
int it = y.fnd(s + 1);
x.edt(it, l * 2);
}
}
for(int i = 1; i <= n; i++)
cout << (x.que(i) - y.que(i)) / 2 << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
0 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
0 ms |
332 KB |
Output is correct |
24 |
Correct |
0 ms |
332 KB |
Output is correct |
25 |
Correct |
0 ms |
332 KB |
Output is correct |
26 |
Correct |
0 ms |
332 KB |
Output is correct |
27 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
0 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
0 ms |
332 KB |
Output is correct |
24 |
Correct |
0 ms |
332 KB |
Output is correct |
25 |
Correct |
0 ms |
332 KB |
Output is correct |
26 |
Correct |
0 ms |
332 KB |
Output is correct |
27 |
Correct |
0 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
460 KB |
Output is correct |
31 |
Correct |
2 ms |
460 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
2 ms |
460 KB |
Output is correct |
35 |
Correct |
2 ms |
460 KB |
Output is correct |
36 |
Correct |
2 ms |
460 KB |
Output is correct |
37 |
Correct |
2 ms |
460 KB |
Output is correct |
38 |
Correct |
2 ms |
460 KB |
Output is correct |
39 |
Correct |
2 ms |
460 KB |
Output is correct |
40 |
Correct |
2 ms |
460 KB |
Output is correct |
41 |
Correct |
1 ms |
460 KB |
Output is correct |
42 |
Correct |
2 ms |
460 KB |
Output is correct |
43 |
Correct |
2 ms |
460 KB |
Output is correct |
44 |
Correct |
2 ms |
460 KB |
Output is correct |
45 |
Correct |
2 ms |
460 KB |
Output is correct |
46 |
Correct |
2 ms |
460 KB |
Output is correct |
47 |
Correct |
2 ms |
484 KB |
Output is correct |
48 |
Correct |
2 ms |
460 KB |
Output is correct |
49 |
Correct |
2 ms |
460 KB |
Output is correct |
50 |
Correct |
1 ms |
460 KB |
Output is correct |
51 |
Correct |
2 ms |
460 KB |
Output is correct |
52 |
Correct |
2 ms |
460 KB |
Output is correct |
53 |
Correct |
1 ms |
460 KB |
Output is correct |
54 |
Correct |
2 ms |
460 KB |
Output is correct |
55 |
Correct |
2 ms |
460 KB |
Output is correct |
56 |
Correct |
2 ms |
460 KB |
Output is correct |
57 |
Correct |
2 ms |
460 KB |
Output is correct |
58 |
Correct |
2 ms |
460 KB |
Output is correct |
59 |
Correct |
2 ms |
460 KB |
Output is correct |
60 |
Correct |
2 ms |
460 KB |
Output is correct |
61 |
Correct |
2 ms |
460 KB |
Output is correct |
62 |
Correct |
1 ms |
460 KB |
Output is correct |
63 |
Correct |
2 ms |
460 KB |
Output is correct |
64 |
Correct |
2 ms |
460 KB |
Output is correct |
65 |
Correct |
2 ms |
460 KB |
Output is correct |
66 |
Correct |
2 ms |
460 KB |
Output is correct |
67 |
Correct |
1 ms |
460 KB |
Output is correct |
68 |
Correct |
2 ms |
460 KB |
Output is correct |
69 |
Correct |
2 ms |
460 KB |
Output is correct |
70 |
Correct |
1 ms |
332 KB |
Output is correct |
71 |
Correct |
1 ms |
460 KB |
Output is correct |
72 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
0 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
0 ms |
332 KB |
Output is correct |
24 |
Correct |
0 ms |
332 KB |
Output is correct |
25 |
Correct |
0 ms |
332 KB |
Output is correct |
26 |
Correct |
0 ms |
332 KB |
Output is correct |
27 |
Correct |
0 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
460 KB |
Output is correct |
31 |
Correct |
2 ms |
460 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
2 ms |
460 KB |
Output is correct |
35 |
Correct |
2 ms |
460 KB |
Output is correct |
36 |
Correct |
2 ms |
460 KB |
Output is correct |
37 |
Correct |
2 ms |
460 KB |
Output is correct |
38 |
Correct |
2 ms |
460 KB |
Output is correct |
39 |
Correct |
2 ms |
460 KB |
Output is correct |
40 |
Correct |
2 ms |
460 KB |
Output is correct |
41 |
Correct |
1 ms |
460 KB |
Output is correct |
42 |
Correct |
2 ms |
460 KB |
Output is correct |
43 |
Correct |
2 ms |
460 KB |
Output is correct |
44 |
Correct |
2 ms |
460 KB |
Output is correct |
45 |
Correct |
2 ms |
460 KB |
Output is correct |
46 |
Correct |
2 ms |
460 KB |
Output is correct |
47 |
Correct |
2 ms |
484 KB |
Output is correct |
48 |
Correct |
2 ms |
460 KB |
Output is correct |
49 |
Correct |
2 ms |
460 KB |
Output is correct |
50 |
Correct |
1 ms |
460 KB |
Output is correct |
51 |
Correct |
2 ms |
460 KB |
Output is correct |
52 |
Correct |
2 ms |
460 KB |
Output is correct |
53 |
Correct |
1 ms |
460 KB |
Output is correct |
54 |
Correct |
2 ms |
460 KB |
Output is correct |
55 |
Correct |
2 ms |
460 KB |
Output is correct |
56 |
Correct |
2 ms |
460 KB |
Output is correct |
57 |
Correct |
2 ms |
460 KB |
Output is correct |
58 |
Correct |
2 ms |
460 KB |
Output is correct |
59 |
Correct |
2 ms |
460 KB |
Output is correct |
60 |
Correct |
2 ms |
460 KB |
Output is correct |
61 |
Correct |
2 ms |
460 KB |
Output is correct |
62 |
Correct |
1 ms |
460 KB |
Output is correct |
63 |
Correct |
2 ms |
460 KB |
Output is correct |
64 |
Correct |
2 ms |
460 KB |
Output is correct |
65 |
Correct |
2 ms |
460 KB |
Output is correct |
66 |
Correct |
2 ms |
460 KB |
Output is correct |
67 |
Correct |
1 ms |
460 KB |
Output is correct |
68 |
Correct |
2 ms |
460 KB |
Output is correct |
69 |
Correct |
2 ms |
460 KB |
Output is correct |
70 |
Correct |
1 ms |
332 KB |
Output is correct |
71 |
Correct |
1 ms |
460 KB |
Output is correct |
72 |
Correct |
1 ms |
460 KB |
Output is correct |
73 |
Correct |
91 ms |
7164 KB |
Output is correct |
74 |
Correct |
93 ms |
9056 KB |
Output is correct |
75 |
Correct |
90 ms |
9216 KB |
Output is correct |
76 |
Correct |
95 ms |
9304 KB |
Output is correct |
77 |
Correct |
95 ms |
9416 KB |
Output is correct |
78 |
Correct |
91 ms |
9280 KB |
Output is correct |
79 |
Correct |
94 ms |
9440 KB |
Output is correct |
80 |
Correct |
83 ms |
9536 KB |
Output is correct |
81 |
Correct |
77 ms |
9828 KB |
Output is correct |
82 |
Correct |
91 ms |
9952 KB |
Output is correct |
83 |
Correct |
84 ms |
10692 KB |
Output is correct |
84 |
Correct |
80 ms |
10680 KB |
Output is correct |
85 |
Correct |
82 ms |
10728 KB |
Output is correct |
86 |
Correct |
83 ms |
11208 KB |
Output is correct |
87 |
Correct |
87 ms |
11864 KB |
Output is correct |
88 |
Correct |
90 ms |
13036 KB |
Output is correct |
89 |
Correct |
88 ms |
13024 KB |
Output is correct |
90 |
Correct |
89 ms |
11484 KB |
Output is correct |
91 |
Correct |
68 ms |
8132 KB |
Output is correct |
92 |
Correct |
71 ms |
8424 KB |
Output is correct |
93 |
Correct |
93 ms |
11720 KB |
Output is correct |
94 |
Correct |
77 ms |
9116 KB |
Output is correct |
95 |
Correct |
83 ms |
11108 KB |
Output is correct |
96 |
Correct |
71 ms |
9064 KB |
Output is correct |
97 |
Correct |
83 ms |
10140 KB |
Output is correct |
98 |
Correct |
80 ms |
9032 KB |
Output is correct |
99 |
Correct |
86 ms |
10952 KB |
Output is correct |
100 |
Correct |
78 ms |
8936 KB |
Output is correct |
101 |
Correct |
83 ms |
10336 KB |
Output is correct |
102 |
Correct |
89 ms |
9164 KB |
Output is correct |
103 |
Correct |
87 ms |
11084 KB |
Output is correct |
104 |
Correct |
83 ms |
8980 KB |
Output is correct |
105 |
Correct |
83 ms |
10612 KB |
Output is correct |
106 |
Correct |
78 ms |
9160 KB |
Output is correct |
107 |
Correct |
82 ms |
10848 KB |
Output is correct |
108 |
Correct |
86 ms |
9024 KB |
Output is correct |
109 |
Correct |
80 ms |
10432 KB |
Output is correct |
110 |
Correct |
74 ms |
9180 KB |
Output is correct |
111 |
Correct |
92 ms |
12040 KB |
Output is correct |
112 |
Correct |
76 ms |
9160 KB |
Output is correct |
113 |
Correct |
91 ms |
12384 KB |
Output is correct |
114 |
Correct |
77 ms |
9288 KB |
Output is correct |
115 |
Correct |
77 ms |
9632 KB |
Output is correct |
116 |
Correct |
75 ms |
9304 KB |
Output is correct |
117 |
Correct |
90 ms |
12360 KB |
Output is correct |
118 |
Correct |
77 ms |
9184 KB |
Output is correct |
119 |
Correct |
28 ms |
5572 KB |
Output is correct |
120 |
Correct |
24 ms |
3792 KB |
Output is correct |