This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
le[0] = lee[0] = ree[n-1] = 0;
re[n-1] = d[n-1];
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 = 0;
for(int k = i+1 ; k < j ; k++) {
//cout << i << ' ' << j << '\n';
x = max(x, lee[k]+d[k]);
x = max(x, ree[k]+d[k]);
//cout << le[i] << ' ' << re[j] << '\n';
x = max(x, le[i]+re[j]+c);
mn = min(mn, x);
}
}
}
return mn;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |