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"
using namespace std;
const int nax = 100;
long long tab[nax][nax];
int sub[nax];
long long main_line[nax];
int expr;
int n;
long long get(int a, int b, int x, int y) {
long long ret = main_line[b] - main_line[a];
ret = min(ret,
abs(main_line[x]-main_line[a])+expr+abs(main_line[y]-main_line[b]));
return ret;
}
long long connect(int a, int b) {
long long ret = 0;
for(int i=0; i<n; ++i) {
for(int j=i+1; j<n; ++j) {
ret = max(ret, get(i, j, a, b)+sub[i]+sub[j]);
}
}
return ret;
}
long long find_shortcut(int N, vector<int> l, vector<int> d, int c) {
n = N;
for(int i=0; i<n; ++i) {
sub[i] = d[i];
if(i) main_line[i] = main_line[i-1] + l[i-1];
}
expr = c;
long long ans = 1e18;
for(int i=0; i<n-1; ++i) {
for(int j=i+1; j<n; ++j) {
ans = min(ans, connect(i, j));
}
}
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... |