#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(ll i=0;i<n-1;i++){
S[i+1] = S[i] + l[i];
}
vector<ll>depth(n,0);
vector<ll>start(n,0);
vector<pair<ll,pair<ll,ll>>> diameters;
depth[0] = d[0];
for(ll 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;
}
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
0 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 59201 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
0 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 59201 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
0 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 59201 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
0 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 59201 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
0 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 59201 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
0 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 59201 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
0 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 59201 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
0 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 59201 |
6 |
Halted |
0 ms |
0 KB |
- |