Submission #827038

#TimeUsernameProblemLanguageResultExecution timeMemory
827038tolbiShortcut (IOI16_shortcut)C++17
0 / 100
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #include "shortcut.h" long long find_shortcut(int n, std::vector<int> _p, std::vector<int> d, int c) { vector<ll> pref; pref.push_back(0); for (int i = 0; i < n-1; i++){ pref.push_back(_p[i]); pref[i+1]+=pref[i]; } function<ll(int,int)> query; query = [&](int l, int r)->ll{ if (l==r) return 0ll; if (r<l) swap(l,r); return pref[r]-pref[l]; }; ll ans = LONG_LONG_MAX; function<ll(int,int)> dene; dene = [&](int l, int r)->ll{ ll crr = 0; for (int i = 0; i < n; i++){ crr=max(crr,(ll)d[i]); for (int j = i+1; j < n; j++){ ll cr1 = query(i,j); ll cr2 = query(l,i)+query(r,j)+c; cr2=min(cr2,query(r,i)+query(l,j)+c); crr=max(crr,min(cr1,cr2)+(ll)d[i]+(ll)d[j]); } } return crr; }; for (int l = 0; l < n; l++){ int ll = l, rr = n-1; while (ll<rr){ int mid = ll+(rr-ll)/2; if (dene(l,mid)<=dene(l,mid+1)){ rr=mid; } else { ll=mid+1; } } ans=min(ans,dene(l,ll)); } 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...