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 ans = LLONG_MAX;
vector<long long>x(n);
x[0] = 0;
for(int i = 1 ; i < n ; i++)
x[i] = x[i-1] + l[i-1];
for(int i = 0 ; i < n ; i++) {
for(int j = i+1 ; j < n ; j++) {
long long mx = 0;
for(int ii = 0 ; ii < n ; ii++) {
for(int jj = ii+1 ; jj < n ; jj++) {
if(jj <= i)
mx = max(mx, x[jj]-x[ii]+d[jj]+d[ii]); // +d
else if(ii >= j)
mx = max(mx, x[jj]-x[ii]+d[jj]+d[ii]);
else if(ii >= i && ii <= j && jj >= j)
mx = max(mx, min(x[jj]-x[ii]+d[ii]+d[jj], x[jj]-x[j]+c+x[ii]-x[i]+d[ii]+d[jj]));
else if(ii <= i && jj >= i && jj <= j)
mx = max(mx, min(x[jj]-x[ii]+d[ii]+d[jj], x[i]-x[ii]+c+x[j]-x[jj]+d[ii]+d[jj]));
else if(ii <= i && jj >= j)
mx = max(mx, min(x[jj]-x[ii]+d[ii]+d[jj], x[jj]-x[j]+c+x[i]-x[ii]+d[ii]+d[jj]));
else
mx = max(mx, min(x[jj]-x[ii]+d[ii]+d[jj], x[j]-x[jj]+c+x[ii]-x[i]+d[ii]+d[jj]));
}
}
//cout << i << ' ' << j << ' ' << mx << '\n';
ans = min(ans, mx);
}
}
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... |