#include "shortcut.h"
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c)
{
vector<ll>S(n,0);
for(int i=0;i<n-1;i++){
S[i+1] = S[i] + l[i];
}
vector<ll>depth(n,0);
vector<int>start(n,0);
vector<pair<ll,pair<int,int>>> diameters;
depth[0] = d[0];
for(int i=1;i<n;i++){
depth[i] = max(l[i-1]+depth[i-1],(ll)d[i]);
if((l[i-1]+depth[i-1]) < d[i]){
start[i] = i;
}
else{
start[i] = start[i-1];
}
diameters.push_back({l[i-1]+depth[i-1]+d[i],{start[i-1],i}});
}
sort(diameters.rbegin(),diameters.rend());
ll max_diameter = diameters[0].first;
max_diameter = min(diameters[0].first - (S[diameters[0].second.second] - S[diameters[0].second.first]) + c,max_diameter);
max_diameter = max(max_diameter,diameters[1].first);
return max_diameter;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
1 ms |
296 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
1 ms |
296 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
1 ms |
296 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
1 ms |
296 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
1 ms |
296 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
1 ms |
296 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
1 ms |
296 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
0 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Incorrect |
1 ms |
296 KB |
n = 4, incorrect answer: jury 3000000001 vs contestant 4000000000 |
15 |
Halted |
0 ms |
0 KB |
- |