#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
const long long INF=1e18;
long long s[1000001];
long long find_shortcut(int n, vector <int> l, vector <int> d, int c){
long long lo=0,hi=INF,kq=-1;
for (int i=1;i<n;i++)
s[i]=s[i-1]+l[i-1];
while (lo<=hi){
long long mid=(lo+hi)>>1,ch=0,mnx=-INF,mxx=INF,mny=-INF,mxy=INF;
for (int i=0;i<n;i++)
for (int j=i+1;j<n;j++)
if (s[j]-s[i]+d[i]+d[j]>mid){
long long sz=mid-d[i]-d[j]-c;
ch=1;
long long a=s[i],b=s[j]-sz,c=s[i],d=s[j]+sz;
a=a+b;
b=a-b*2;
c=c+d;
d=c-d*2;
mnx=max(mnx,a);
mxx=min(mxx,c);
mny=max(mny,d);
mxy=min(mxy,b);
}
if (ch){
for (int i=0;i<n;i++)
for (int j=i+1;j<n;j++)
if (s[j]-s[i]+d[i]+d[j]>mid){
long long x=s[i]+s[j],y=s[i]-s[j];
if (mnx<=x&&x<=mxx&&mny<=y&&y<=mxy)
ch=0;
}
}
if (!ch){
kq=mid;
hi=mid-1;
}
else
lo=mid+1;
}
return kq;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
348 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
348 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
348 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
348 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
348 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
600 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
348 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
348 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
348 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
348 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
444 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
348 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
348 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
0 ms |
348 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
348 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
344 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
344 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
444 KB |
n = 10, 117 is a correct answer |
24 |
Incorrect |
0 ms |
444 KB |
n = 10, incorrect answer: jury 336 vs contestant 338 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
348 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
348 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
348 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
348 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
348 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
600 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
348 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
348 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
348 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
348 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
444 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
348 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
348 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
0 ms |
348 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
348 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
344 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
344 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
444 KB |
n = 10, 117 is a correct answer |
24 |
Incorrect |
0 ms |
444 KB |
n = 10, incorrect answer: jury 336 vs contestant 338 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
348 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
348 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
348 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
348 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
348 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
600 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
348 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
348 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
348 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
348 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
444 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
348 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
348 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
0 ms |
348 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
348 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
344 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
344 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
444 KB |
n = 10, 117 is a correct answer |
24 |
Incorrect |
0 ms |
444 KB |
n = 10, incorrect answer: jury 336 vs contestant 338 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
348 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
348 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
348 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
348 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
348 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
600 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
348 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
348 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
348 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
348 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
444 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
348 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
348 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
0 ms |
348 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
348 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
344 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
344 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
444 KB |
n = 10, 117 is a correct answer |
24 |
Incorrect |
0 ms |
444 KB |
n = 10, incorrect answer: jury 336 vs contestant 338 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
348 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
348 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
348 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
348 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
348 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
600 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
348 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
348 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
348 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
348 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
444 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
348 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
348 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
0 ms |
348 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
348 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
344 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
344 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
444 KB |
n = 10, 117 is a correct answer |
24 |
Incorrect |
0 ms |
444 KB |
n = 10, incorrect answer: jury 336 vs contestant 338 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
348 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
348 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
348 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
348 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
348 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
600 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
348 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
348 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
348 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
348 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
444 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
348 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
348 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
0 ms |
348 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
348 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
344 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
344 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
444 KB |
n = 10, 117 is a correct answer |
24 |
Incorrect |
0 ms |
444 KB |
n = 10, incorrect answer: jury 336 vs contestant 338 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
348 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
348 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
348 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
348 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
348 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
600 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
348 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
348 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
348 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
348 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
444 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
348 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
348 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
0 ms |
348 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
348 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
344 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
344 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
444 KB |
n = 10, 117 is a correct answer |
24 |
Incorrect |
0 ms |
444 KB |
n = 10, incorrect answer: jury 336 vs contestant 338 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
348 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
348 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
348 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
348 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
348 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
348 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
600 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
348 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
348 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
348 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
348 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
348 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
444 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
348 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
348 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
0 ms |
348 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
348 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
344 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
344 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
444 KB |
n = 10, 117 is a correct answer |
24 |
Incorrect |
0 ms |
444 KB |
n = 10, incorrect answer: jury 336 vs contestant 338 |
25 |
Halted |
0 ms |
0 KB |
- |