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 <bits/stdc++.h>
#include "shortcut.h"
#define ll long long
using namespace std;
const int maxn = 505;
const ll inf = (1LL << 60);
ll dpoc[maxn];
ll find_shortcut(int n, vector<int> l, vector<int> d, int c){
for(int i = 1; i < n; i++){
dpoc[i] = dpoc[i - 1] + l[i - 1];
}
ll ans = inf;
for(int a = 0; a < n; a++){
for(int b = a + 1; b < n; b++){
ll maks = 0;
for(int x = 0; x < n; x++){
for(int y = x + 1; y < n; y++){
ll dxa = abs(dpoc[x] - dpoc[a]);
ll dxb = abs(dpoc[x] - dpoc[b]);
ll dya = abs(dpoc[y] - dpoc[a]);
ll dyb = abs(dpoc[y] - dpoc[b]);
ll dxy = abs(dpoc[x] - dpoc[y]);
dxa = min(dxa, dxb + c);
dxb = min(dxb, dxa + c);
dya = min(dya, dyb + c);
dyb = min(dyb, dya + c);
// maks = max(maks, dxy + d[x] + d[y]);
maks = max(maks, min(dxy, min(dxa + dya, dxb + dyb)) + d[x] + d[y]);
// if(maks == 110) cout << x << ' ' << y << ' ' << dxa << ' ' << dya << endl;
}
}
// cout << a << ' ' << b << ' ' << maks << endl;
ans = min(ans, maks);
}
}
return ans;
}
# | 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... |