# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600609 | 8e7 | Shortcut (IOI16_shortcut) | C++17 | 2086 ms | 2260 KiB |
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"
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
const ll inf = 1LL<<60;
long long find_shortcut(int n, vector<int> L, vector<int> D, int c) {
vector<vector<ll> > d(2*n, vector<ll>(2*n, 0));
vector<ll> pref(n, 0);
for (int i = 0;i < n - 1;i++) pref[i+1] = pref[i] + L[i];
for (int i = 0;i < 2*n;i++) {
for (int j = i+1;j < 2*n;j++) {
ll p = pref[j/2] - pref[i/2];
if (j % 2) p += D[j/2];
if (i % 2) p += D[i/2];
d[i][j] = d[j][i] = p;
}
}
ll ans = inf;
for (int a = 0;a < 2*n;a += 2) {
for (int b = 2;b < 2*n;b += 2) {
ll val = 0;
for (int i = 0;i < 2*n;i++) {
for (int j = i+1;j < 2*n;j++) {
val = max(val, min(d[a][i] + d[b][j] + c, d[i][j]));
}
}
debug(a, b, val);
ans = min(ans, val);
}
}
return ans;
}
Compilation message (stderr)
# | 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... |