#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));
}
}
}
for(int x = 0; x < n; x++){
for(int y = 0; y < n; y++){
int a = p[x] + p[y];
int b = p[y] - p[x];
if(x1 <= a && a <= x2 && y1 <= b && b <= y2) return true;
}
}
return false;
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 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 |
1 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
256 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 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 |
0 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 |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
0 ms |
256 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 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 |
1 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
256 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 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 |
0 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 |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
0 ms |
256 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 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 |
1 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
256 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 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 |
0 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 |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
0 ms |
256 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 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 |
1 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
256 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 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 |
0 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 |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
0 ms |
256 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 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 |
1 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
256 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 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 |
0 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 |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
0 ms |
256 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 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 |
1 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
256 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 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 |
0 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 |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
0 ms |
256 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 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 |
1 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
256 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 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 |
0 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 |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
0 ms |
256 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 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 |
1 ms |
256 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
256 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
256 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 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 |
0 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 |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
0 ms |
256 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |