#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
using ll = long long;
ll find_shortcut(int n, vector<int> l, vector<int> d, int c) {
vector<ll> x(n, 0);
for (int i = 0; i + 1 < n; i++) {
x[i + 1] = x[i] + (ll)l[i];
}
auto good = [&](ll k) {
ll min_x = LLONG_MIN, max_x = LLONG_MAX, min_y = LLONG_MIN, max_y = LLONG_MAX;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if ((ll)d[i] + (ll)d[j] + x[j] - x[i] > k) {
ll v = k - (ll)c - (ll)d[i] - (ll)d[j];
pair<ll, ll> lower_left = mp(x[i] - v - x[j], x[i] - v + x[j]);
pair<ll, ll> upper_right = mp(x[i] + v - x[j], x[i] + v + x[j]);
min_x = max(min_x, lower_left.first);
max_x = min(max_x, upper_right.first);
min_y = max(min_y, lower_left.second);
max_y = min(max_y, upper_right.second);
}
}
}
return (bool)(min_x <= max_x && min_y <= max_y);
};
ll lo = 0, hi = (ll)1e16, ans = -1;
while (lo <= hi) {
ll mid = (lo + hi) / 2;
if (good(mid)) {
ans = mid;
hi = mid - 1;
} else {
lo = mid + 1;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
0 ms |
212 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
0 ms |
212 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
0 ms |
212 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
0 ms |
212 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
0 ms |
212 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
0 ms |
212 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
0 ms |
212 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
0 ms |
212 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |