Submission #393223

#TimeUsernameProblemLanguageResultExecution timeMemory
393223biggBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms332 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e7 + 10; ll np[MAXN]; ll Nl; 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++){ np[i] = p[i]; } Nl = L; for(int i = 0; i < N; i++){ pref[i] = np[i]; if(i >= K) pref[i] += pref[i-K]; } for(int i = N - 1; i >= 0; i--){ suf[i] = L-np[i]; if(N-i > K) { 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); // achar volta if(K < N){ for(int i = 1; i+K < N; i++ ){ ans = min(ans, L + 2*pref[i-1] + 2*pref[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...