# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
870025 |
2023-11-06T16:30:01 Z |
Pannda |
Snowball (JOI21_ho_t2) |
C++17 |
|
115 ms |
8520 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, T;
cin >> n >> T;
T++;
vector<long long> x(n);
for (int i = 0; i < n; i++) {
cin >> x[i];
}
vector<long long> delta(T, 0);
vector<long long> mx(T, 0), mn(T, 0);
for (int t = 1; t < T; t++) {
long long d;
cin >> d;
delta[t] = delta[t - 1] + d;
mx[t] = max(mx[t - 1], delta[t]);
mn[t] = min(mn[t - 1], delta[t]);
}
auto getL = [&](int i) {
if (i == 0 || x[i - 1] + mx.back() <= x[i] + mn.back()) return x[i] + mn.back();
int l = 0, r = T - 1;
while (l < r) {
int t = (l + r + 1) >> 1;
if (x[i - 1] + mx[t] <= x[i] + mn[t]) {
l = t;
} else {
r = t - 1;
}
}
assert(l != T - 1);
if (x[i - 1] + mx[l + 1] > x[i] + mn[l]) return x[i] + mn[l];
if (x[i - 1] + mx[l] > x[i] + mn[l + 1]) return x[i - 1] + mx[l];
assert(false);
};
auto getR = [&](int i) {
if (i == n - 1 || x[i] + mx.back() <= x[i + 1] + mn.back()) return x[i] + mx.back();
int l = 0, r = T - 1;
while (l < r) {
int t = (l + r + 1) >> 1;
if (x[i] + mx[t] <= x[i + 1] + mn[t]) {
l = t;
} else {
r = t - 1;
}
}
assert(l != T - 1);
if (x[i] + mx[l + 1] > x[i + 1] + mn[l]) return x[i + 1] + mn[l];
if (x[i] + mx[l] > x[i + 1] + mn[l + 1]) return x[i] + mx[l];
assert(false);
};
for (int i = 0; i < n; i++) {
cout << getR(i) - getL(i) << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
20 ms |
4956 KB |
Output is correct |
21 |
Correct |
18 ms |
4956 KB |
Output is correct |
22 |
Correct |
17 ms |
4956 KB |
Output is correct |
23 |
Correct |
18 ms |
5184 KB |
Output is correct |
24 |
Correct |
25 ms |
5372 KB |
Output is correct |
25 |
Correct |
115 ms |
8252 KB |
Output is correct |
26 |
Correct |
99 ms |
8276 KB |
Output is correct |
27 |
Correct |
100 ms |
7884 KB |
Output is correct |
28 |
Correct |
101 ms |
8016 KB |
Output is correct |
29 |
Correct |
105 ms |
7768 KB |
Output is correct |
30 |
Correct |
93 ms |
7376 KB |
Output is correct |
31 |
Correct |
51 ms |
7272 KB |
Output is correct |
32 |
Correct |
38 ms |
7012 KB |
Output is correct |
33 |
Correct |
9 ms |
1112 KB |
Output is correct |
34 |
Correct |
106 ms |
8520 KB |
Output is correct |
35 |
Correct |
101 ms |
8020 KB |
Output is correct |
36 |
Correct |
101 ms |
8276 KB |
Output is correct |
37 |
Correct |
100 ms |
8004 KB |
Output is correct |
38 |
Correct |
108 ms |
8092 KB |
Output is correct |
39 |
Correct |
98 ms |
8020 KB |
Output is correct |
40 |
Correct |
59 ms |
8020 KB |
Output is correct |
41 |
Correct |
20 ms |
4952 KB |
Output is correct |
42 |
Correct |
39 ms |
6992 KB |
Output is correct |
43 |
Correct |
65 ms |
8336 KB |
Output is correct |
44 |
Correct |
19 ms |
4956 KB |
Output is correct |
45 |
Correct |
43 ms |
8040 KB |
Output is correct |
46 |
Correct |
61 ms |
8296 KB |
Output is correct |
47 |
Correct |
65 ms |
8260 KB |
Output is correct |
48 |
Correct |
60 ms |
8264 KB |
Output is correct |