#include <bits/stdc++.h>
using namespace std;
const int c=502;
vector<int> pl;
long long ans=0, kom[c], ert, maxi, maxj, am, tav[c][c];
long long dist(int a, int b) {
return pl[a]+pl[b]+abs(kom[b]-kom[a]);
}
long long find_shortcut(int n, vector<int> sz, vector<int> s, int d) {
for (int i=0; i<n-1; i++) kom[i+1]=kom[i]+sz[i];
for (int i=0; i<n; i++) pl.push_back(s[i]);
for (int i=0; i<n; i++) for (int j=0; j<n; j++) tav[i][j]=dist(i, j), ans=max(ans, tav[i][j]);
for (int i=0; i<n; i++) for (int j=i+1; j<n; j++) {
ert=0, maxi=0, maxj=0;
for (int k=0; k<i; k++) maxi=max(maxi, tav[k][i]-pl[i]);
for (int k=j+1; k<n; k++) maxj=max(maxj, tav[k][j]-pl[j]);
ert=maxi+maxj+d;
for (int k=i; k<=j; k++) {
long long tavi=min(tav[k][i]-pl[i], tav[k][j]-pl[j]+d), tavj=min(tav[k][j]-pl[j], tav[k][i]-pl[i]+d);
ert=max({ert, tavi+maxi, tavj+maxj});
for (int l=k+1; l<=j; l++) {
long long x=min(tav[l][i]-pl[i], tav[l][j]-pl[j]+d);
ert=max(ert, min(x+tavi, tav[k][l]));
}
}
ans=min(ans, ert);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
384 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
384 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
384 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
384 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
384 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
384 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
384 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
1 ms |
384 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
384 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
384 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
384 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
384 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
384 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
384 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
384 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
384 KB |
n = 2, 122 is a correct answer |
23 |
Incorrect |
0 ms |
384 KB |
n = 10, incorrect answer: jury 117 vs contestant 110 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
384 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
384 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
384 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
384 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
384 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
384 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
384 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
1 ms |
384 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
384 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
384 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
384 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
384 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
384 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
384 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
384 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
384 KB |
n = 2, 122 is a correct answer |
23 |
Incorrect |
0 ms |
384 KB |
n = 10, incorrect answer: jury 117 vs contestant 110 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
384 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
384 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
384 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
384 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
384 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
384 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
384 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
1 ms |
384 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
384 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
384 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
384 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
384 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
384 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
384 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
384 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
384 KB |
n = 2, 122 is a correct answer |
23 |
Incorrect |
0 ms |
384 KB |
n = 10, incorrect answer: jury 117 vs contestant 110 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
384 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
384 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
384 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
384 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
384 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
384 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
384 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
1 ms |
384 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
384 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
384 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
384 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
384 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
384 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
384 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
384 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
384 KB |
n = 2, 122 is a correct answer |
23 |
Incorrect |
0 ms |
384 KB |
n = 10, incorrect answer: jury 117 vs contestant 110 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
384 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
384 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
384 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
384 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
384 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
384 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
384 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
1 ms |
384 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
384 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
384 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
384 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
384 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
384 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
384 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
384 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
384 KB |
n = 2, 122 is a correct answer |
23 |
Incorrect |
0 ms |
384 KB |
n = 10, incorrect answer: jury 117 vs contestant 110 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
384 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
384 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
384 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
384 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
384 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
384 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
384 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
1 ms |
384 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
384 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
384 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
384 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
384 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
384 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
384 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
384 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
384 KB |
n = 2, 122 is a correct answer |
23 |
Incorrect |
0 ms |
384 KB |
n = 10, incorrect answer: jury 117 vs contestant 110 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
384 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
384 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
384 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
384 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
384 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
384 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
384 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
1 ms |
384 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
384 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
384 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
384 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
384 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
384 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
384 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
384 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
384 KB |
n = 2, 122 is a correct answer |
23 |
Incorrect |
0 ms |
384 KB |
n = 10, incorrect answer: jury 117 vs contestant 110 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
384 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
384 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
384 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
384 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
384 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
384 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
384 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
384 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
384 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
0 ms |
384 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
1 ms |
384 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
384 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
384 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
384 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
384 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
384 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
0 ms |
384 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
0 ms |
384 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
0 ms |
384 KB |
n = 2, 122 is a correct answer |
23 |
Incorrect |
0 ms |
384 KB |
n = 10, incorrect answer: jury 117 vs contestant 110 |
24 |
Halted |
0 ms |
0 KB |
- |