#include "shortcut.h"
#include <iostream>
#include <algorithm>
using namespace std;
long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c)
{
vector<int>S(n,0);
for(int i=0;i<n-1;i++){
S[i+1] = S[i] + l[i];
}
vector<int>depth(n,0);
vector<int>start(n,0);
vector<pair<int,pair<int,int>>> diameters;
depth[0] = d[0];
for(int i=1;i<n;i++){
depth[i] = max(l[i-1]+depth[i-1],d[i]);
if(S[i] < 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());
int max_diameter = diameters[0].first - (S[diameters[0].second.second] - S[diameters[0].second.first]) + c;
max_diameter = max(max_diameter,diameters[1].first);
return max_diameter;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
Incorrect |
1 ms |
304 KB |
n = 3, incorrect answer: jury 4 vs contestant 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
Incorrect |
1 ms |
304 KB |
n = 3, incorrect answer: jury 4 vs contestant 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
Incorrect |
1 ms |
304 KB |
n = 3, incorrect answer: jury 4 vs contestant 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
Incorrect |
1 ms |
304 KB |
n = 3, incorrect answer: jury 4 vs contestant 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
Incorrect |
1 ms |
304 KB |
n = 3, incorrect answer: jury 4 vs contestant 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
Incorrect |
1 ms |
304 KB |
n = 3, incorrect answer: jury 4 vs contestant 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
Incorrect |
1 ms |
304 KB |
n = 3, incorrect answer: jury 4 vs contestant 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
Incorrect |
1 ms |
304 KB |
n = 3, incorrect answer: jury 4 vs contestant 5 |
5 |
Halted |
0 ms |
0 KB |
- |