Submission #616042

#TimeUsernameProblemLanguageResultExecution timeMemory
616042PiejanVDCShortcut (IOI16_shortcut)C++17
23 / 100
2039 ms304 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...