#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
using namespace std;
#include "shortcut.h"
int64_t n, c;
vector<int64_t> d;
vector<int64_t> p;
bool ok(int64_t k){
int64_t x1 = -1e18, x2 = 1e18, y1 = -1e18, y2 = 1e18;
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
if(d[i] + d[j] + p[j] - p[i] > k){
x1 = max(x1, p[i] + p[j] - (k - d[i] - d[j] - c));
x2 = min(x2, p[i] + p[j] + (k - d[i] - d[j] - c));
y1 = max(y1, p[j] - p[i] - (k - d[i] - d[j] - c));
y2 = min(y2, p[j] - p[i] + (k - d[i] - d[j] - c));
}
}
}
return x1 <= x2 && y1 <= y2;
}
long long find_shortcut(int N, std::vector<int> l, std::vector<int> D, int C){
n = N;
c = C;
for(auto x : D) d.pb(x);
p = vector<int64_t>(n, 0);
for(int i = 1; i < n; i++) p[i] = p[i - 1] + l[i - 1];
int64_t a = 0, b = 1e18, ans = 1e18;
while(a <= b){
int64_t m = (a + b) / 2;
if(ok(m)){
ans = m;
b = m - 1;
}
else a = m + 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
256 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
256 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
256 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
256 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
256 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
256 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
256 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
256 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
1 ms |
368 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
256 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
256 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
256 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
256 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
256 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
256 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
256 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
256 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
1 ms |
368 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
256 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
256 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
256 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
256 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
256 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
256 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
256 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
256 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
1 ms |
368 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
256 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
256 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
256 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
256 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
256 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
256 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
256 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
256 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
1 ms |
368 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
256 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
256 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
256 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
256 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
256 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
256 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
256 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
256 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
1 ms |
368 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
256 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
256 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
256 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
256 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
256 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
256 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
256 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
256 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
1 ms |
368 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
256 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
256 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
256 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
256 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
256 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
256 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
256 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
256 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
1 ms |
368 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
256 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
256 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
256 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
256 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
256 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
256 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
256 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
256 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Incorrect |
1 ms |
368 KB |
n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317 |
18 |
Halted |
0 ms |
0 KB |
- |