#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll prefix[3005];
ll bestB[3005];
ll bestA[3005];
long long find_shortcut(int n, vector<int> l, vector<int> d, int c) {
vector<int> L = {0,0};
for(auto i: l) L.push_back(i);
l=L;
vector<ll> D = {0};
for(auto i: d) D.push_back(i);
d.clear();
for(auto i: D) d.push_back(i);
for(int i = 1; i <= n; i++)
prefix[i] = prefix[i-1] + l[i];
ll diam = 1ll<<50;
vector<ll> Db = D;
for(int i = 2; i <= n; i++)
Db[i] = max(Db[i], Db[i-1]+(ll)l[i]);
vector<ll> Da = D;
for(int i = n-1; i >= 1; i--)
Da[i] = max(Da[i], Da[i+1]+(ll)l[i+1]);
// cerr << " ";
// for(int i = 2; i <= n; i++)
// cerr << l[i] << " ";
// cerr << endl;
// for(int i = 1; i <= n; i++) {
// cerr << d[i] << " ";
// if(d[i]==0)
// cerr << " ";
// }
// cerr << endl;
// cerr << endl;
//
// for(int i = 1; i <= n; i++)
// cerr << Db[i] << " ";
// cerr << endl;
// cerr << endl;
// for(int i = 1; i <= n; i++)
// cerr << Da[i] << " ";
// cerr << endl;
// cerr << endl;
for(int i = 1; i <= n; i++)
for(int j = i+1; j <= n; j++)
bestB[j] = max(bestB[j], prefix[j]-prefix[i] + (ll)d[i] + (ll)d[j]),
bestA[i] = max(bestA[i], prefix[j]-prefix[i] + (ll)d[i] + (ll)d[j]);
for(int i = 2; i <= n; i++)
bestB[i] = max(bestB[i], bestB[i-1]);
for(int i = n-1; i >= 1; i--)
bestA[i] = max(bestA[i], bestA[i+1]);
// for(int i = 1; i <= n; i++)
// cerr << bestB[i] << " ";
// cerr << endl;
// for(int i = 1; i <= n; i++)
// cerr << bestA[i] << " ";
// cerr << endl;
// cerr << endl;
for(ll ci = 1; ci <= n; ci++) {
for(ll cj = ci+1; cj <= n; cj++) {
D[ci] = Db[ci];
D[cj] = Da[cj];
ll currDiam = max(bestB[ci], bestA[cj]);
ll j = 0;
for(ll i = ci; i <= cj; i++) {
for(j = max(j, i+1); j <= cj; j++) {
currDiam = max(currDiam, min(prefix[j]-prefix[i] + D[i] + D[j], prefix[cj]-prefix[j] + c + prefix[i]-prefix[ci] + D[i] + D[j]));
if(j == cj || (min(prefix[j+1]-prefix[i] + D[i], prefix[cj]-prefix[j+1] + c + prefix[i]-prefix[ci] + D[i]))<(min(prefix[j]-prefix[i] + D[i], prefix[cj]-prefix[j] + c + prefix[i]-prefix[ci] + D[i])))
break;
}
}
diam = min(diam, currDiam);
D[ci] = d[ci];
D[cj] = d[cj];
}
}
return diam;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
n = 4, incorrect answer: jury 80 vs contestant 60 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
n = 4, incorrect answer: jury 80 vs contestant 60 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
n = 4, incorrect answer: jury 80 vs contestant 60 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
n = 4, incorrect answer: jury 80 vs contestant 60 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
n = 4, incorrect answer: jury 80 vs contestant 60 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
n = 4, incorrect answer: jury 80 vs contestant 60 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
n = 4, incorrect answer: jury 80 vs contestant 60 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
n = 4, incorrect answer: jury 80 vs contestant 60 |
2 |
Halted |
0 ms |
0 KB |
- |