#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);
if (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; 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 |
0 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 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 |
Incorrect |
0 ms |
256 KB |
n = 2, incorrect answer: jury 62 vs contestant 71 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 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 |
Incorrect |
0 ms |
256 KB |
n = 2, incorrect answer: jury 62 vs contestant 71 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 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 |
Incorrect |
0 ms |
256 KB |
n = 2, incorrect answer: jury 62 vs contestant 71 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 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 |
Incorrect |
0 ms |
256 KB |
n = 2, incorrect answer: jury 62 vs contestant 71 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 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 |
Incorrect |
0 ms |
256 KB |
n = 2, incorrect answer: jury 62 vs contestant 71 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 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 |
Incorrect |
0 ms |
256 KB |
n = 2, incorrect answer: jury 62 vs contestant 71 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 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 |
Incorrect |
0 ms |
256 KB |
n = 2, incorrect answer: jury 62 vs contestant 71 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 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 |
Incorrect |
0 ms |
256 KB |
n = 2, incorrect answer: jury 62 vs contestant 71 |
6 |
Halted |
0 ms |
0 KB |
- |