Submission #393230

#TimeUsernameProblemLanguageResultExecution timeMemory
393230biggBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
522 ms196120 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e7 + 10; ll pref[MAXN], suf[MAXN]; const ll INF = 1e18 + 10; long long delivery(int N, int K, int L, int p[]) { for(int i = 0; i < N; i++){ pref[i] = p[i]; if(!(i < K)) pref[i] += pref[i-K]; } for(int i = N - 1; i >= 0; i--){ suf[i] = L-p[i]; if(!(K+i >= N)) { suf[i] += suf[i+K]; } } // vai e volta por um lado ll ans = min(2*suf[0], 2*pref[N-1]); if(K >= N) ans = min(ans, (ll) L); for(int i = 0; i < N-1; i++) ans = min(ans, 2*suf[i+1] + 2*pref[i]); // achar volta if(K < N){ for(int i = 1; i+K < N; i++ ){ ans = min(ans, L + 2*pref[i-1] + 2*suf[i+K]); } ans = min(ans, L + 2*pref[N-K-1]); ans = min(ans, L + 2*suf[K]); // dou a volta, e pego o resto com uma ida do outro lado } return ans; //return 0; }
#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...