# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
372740 |
2021-03-01T12:06:04 Z |
SeDunion |
Snowball (JOI21_ho_t2) |
C++17 |
|
1102 ms |
8544 KB |
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 66;
const ll INF = 1e18 + 123;
ll L[N], R[N], x[N], shit[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n, q;
cin >> n >> q;
for (int i = 1 ; i <= n ; ++ i) cin >> x[i];
x[n + 1] = INF, x[0] = -INF;
ll loc = 0;
for (int i = 1 ; i <= q ; ++ i) {
ll W; cin >> W;
loc += W;
L[i] = min(L[i - 1], loc);
R[i] = max(R[i - 1], loc);
}
for (int i = 1 ; i <= n ; ++ i) {
ll l = max(x[i - 1], x[i] + L[q]), r = x[i];
while (l < r) {
ll m = (l + r) >> 1ll;
int tl = 0, tr = q;
while (tl < tr) {
int tm = (tl + tr) >> 1;
if (x[i] + L[tm] <= m) {
tr = tm;
} else {
tl = tm + 1;
}
}
if (x[i - 1] + R[tr] <= m) {
r = m;
} else {
l = m + 1;
}
}
//cerr << i << " " << x[i] << " L reach: " << r << "\n";
shit[i] += x[i] - r;
}
for (int i = 1 ; i <= n ; ++ i) {
ll l = x[i], r = min(x[i + 1], x[i] + R[q]);
while (l < r) {
ll m = (l + r + 1) >> 1ll;
int tl = 0, tr = q;
while (tl < tr) {
int tm = (tl + tr) >> 1;
if (R[tm] + x[i] >= m) {
tr = tm;
} else {
tl = tm + 1;
}
}
if (x[i + 1] + L[tr] >= m) {
l = m;
} else {
r = m - 1;
}
}
//cerr << i << " " << x[i] << " R reach: " << l << "\n";
shit[i] += l - x[i];
}
for (int i = 1 ; i <= n ; ++ i) {
cout << shit[i] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
492 KB |
Output is correct |
6 |
Correct |
5 ms |
492 KB |
Output is correct |
7 |
Correct |
4 ms |
492 KB |
Output is correct |
8 |
Correct |
4 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
492 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
7 ms |
492 KB |
Output is correct |
16 |
Correct |
7 ms |
492 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
492 KB |
Output is correct |
6 |
Correct |
5 ms |
492 KB |
Output is correct |
7 |
Correct |
4 ms |
492 KB |
Output is correct |
8 |
Correct |
4 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
492 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
7 ms |
492 KB |
Output is correct |
16 |
Correct |
7 ms |
492 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
20 |
Correct |
30 ms |
3456 KB |
Output is correct |
21 |
Correct |
28 ms |
3436 KB |
Output is correct |
22 |
Correct |
29 ms |
3564 KB |
Output is correct |
23 |
Correct |
40 ms |
3564 KB |
Output is correct |
24 |
Correct |
141 ms |
3948 KB |
Output is correct |
25 |
Correct |
1087 ms |
8284 KB |
Output is correct |
26 |
Correct |
1075 ms |
8544 KB |
Output is correct |
27 |
Correct |
974 ms |
8172 KB |
Output is correct |
28 |
Correct |
938 ms |
8172 KB |
Output is correct |
29 |
Correct |
862 ms |
8056 KB |
Output is correct |
30 |
Correct |
429 ms |
7532 KB |
Output is correct |
31 |
Correct |
110 ms |
7148 KB |
Output is correct |
32 |
Correct |
69 ms |
7020 KB |
Output is correct |
33 |
Correct |
82 ms |
1132 KB |
Output is correct |
34 |
Correct |
985 ms |
8428 KB |
Output is correct |
35 |
Correct |
973 ms |
8172 KB |
Output is correct |
36 |
Correct |
1102 ms |
8300 KB |
Output is correct |
37 |
Correct |
1004 ms |
8064 KB |
Output is correct |
38 |
Correct |
964 ms |
8404 KB |
Output is correct |
39 |
Correct |
947 ms |
8084 KB |
Output is correct |
40 |
Correct |
526 ms |
8136 KB |
Output is correct |
41 |
Correct |
31 ms |
3436 KB |
Output is correct |
42 |
Correct |
62 ms |
7020 KB |
Output is correct |
43 |
Correct |
312 ms |
8300 KB |
Output is correct |
44 |
Correct |
35 ms |
3436 KB |
Output is correct |
45 |
Correct |
535 ms |
8044 KB |
Output is correct |
46 |
Correct |
331 ms |
8300 KB |
Output is correct |
47 |
Correct |
354 ms |
8300 KB |
Output is correct |
48 |
Correct |
200 ms |
8300 KB |
Output is correct |