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];
lee[0] = ree[n-1] = 0;
re[n-1] = d[n-1];
le[0] = d[0];
long long mn = 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];
mn = max(mn, lee[i]+d[i]);
}
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];
}
for(int i = 0 ; i < n ; i++) {
for(int j = i+1 ; j < n ; j++) {
long long x = 0;
for(int k = 0 ; k < j ; k++)
x = max(x, lee[k]+d[k]);
for(int k = i+1 ; k < n ; k++)
x = max(x, ree[k]+d[k]);
long long LE[n], LEE[n];
LE[j] = max(le[i]+(long long)c, (long long)d[j]);
LEE[j] = le[i]+c;
x = max(x, LEE[j]+d[j]);
for(int k = j+1 ; k < n ; k++) {
LE[k] = max(LE[k-1]+(long long)l[k-1], (long long)d[k]), LEE[k] = LE[k-1]+(long long)l[k-1];
x = max(x, LEE[k]+(long long)d[k]);
}
long long RE[n], REE[n];
RE[i] = max((long long)re[j]+(long long)c, (long long)d[i]);
REE[i] = re[j]+(long long)c;
x = max(x, REE[i]+(long long)d[i]);
for(int k = i-1 ; k >= 0 ; k--) {
RE[k] = max(RE[k+1]+(long long)l[k], (long long)d[k]), REE[k] = RE[k+1]+l[k];
x = max(x, REE[k]+(long long)d[k]);
}
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... |