# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575541 | definitelynotmee | Shortcut (IOI16_shortcut) | C++98 | 2091 ms | 340 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<bits/stdc++.h>
#include"shortcut.h"
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
using namespace std;
template <typename T>
using matrix = vector<vector<T>>;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const double EPS = 1e-7;
const int MOD = 1e9 + 7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
const int MAXN = 1e6+1;
long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c){
vector<ll> pref(n);
for(int i = 1; i < n; i++){
pref[i] = pref[i-1]+l[i-1];
}
ll resp = INFL, optl, optr;
for(int l = 0; l < n; l++){
for(int r = l+1; r < n; r++){
ll maxi = 0;
ll cycle = pref[r]-pref[l]+c;
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
if(l <= i){
if(j <= r){
maxi = max(maxi,min(cycle-(pref[j]-pref[i]), pref[j]-pref[i]) + d[i]+d[j]);
} else {
//cout << l << ' ' << r << "=>" << i << ' ' << j << ": " << pref[j]-pref[r] << ' ' << pref[r]-pref[i] << ' ' << pref[i]-pref[l]+c << ' ' << d[i]+d[j] << '\n';
maxi = max(maxi, pref[j]-pref[r] + min(pref[r]-pref[i], pref[i]-pref[l]+c)+d[i]+d[j]);
}
} else {
if(j <= r){
maxi = max(maxi, pref[l]-pref[i] + min(pref[j]-pref[l], pref[r]-pref[j]+c)+d[i]+d[j]);
} else {
maxi = max(maxi,pref[j]-pref[i] - max(0ll,pref[r]-pref[l]-c)+d[i]+d[j]);
}
}
}
}
if(maxi < resp){
optl = l, optr = r;
}
resp = min(resp,maxi);
}
}
// cout << optl << ' ' << optr << '\n';
return resp;
}
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... |