#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
long long find_shortcut(int n, vector<int>l, vector<int>d, int c) {
long long le[n], re[n], lee[n], ree[n];
lee[0] = ree[n-1] = 0;
re[n-1] = d[n-1];
le[0] = d[0];
for(int i = 1 ; i < n ; i++) {
le[i] = max(le[i-1]+(long long)l[i-1], (long long)d[i]), lee[i] = le[i-1]+l[i-1];
}
for(int j = n-2 ; j >= 0 ; j--) {
re[j] = max(re[j+1] + (long long)l[j], (long long)d[j]), ree[j] = re[j+1] + l[j];
}
long long mn = (long long)1e18;
for(int i = 0 ; i < n ; i++) {
for(int j = i+1 ; j < n ; j++) {
long long x = -1;
for(int k = i+1 ; k < j ; k++) {
//cout << i << ' ' << j << ' ' << k << '\n';
x = max(x, lee[k]+d[k]);
x = max(x, ree[k]+d[k]);
//cout << lee[k] << ' ' << ree[k] << '\n';
x = max(x, le[i]+re[j]+c);
//cout << mn << '\n';
}
if(x > -1)
mn = min(mn, x);
}
}
return mn;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 21 vs contestant 22 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 21 vs contestant 22 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 21 vs contestant 22 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 21 vs contestant 22 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 21 vs contestant 22 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 21 vs contestant 22 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 21 vs contestant 22 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 21 vs contestant 22 |
4 |
Halted |
0 ms |
0 KB |
- |