Submission #102246

#TimeUsernameProblemLanguageResultExecution timeMemory
102246Leonardo_PaesBoxes with souvenirs (IOI15_boxes)C++11
100 / 100
605 ms294116 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e7 + 10; typedef long long ll; ll pre[MAXN], suf[MAXN]; ll delivery(int N, int K, int L, int positions[]){ ll sum; for(int i=0; i<N; i++){ pre[i] = 2ll*positions[i]; if(i >= K)pre[i] += pre[i-K]; } for(int i=N-1; i>=0; i--){ suf[i] = 2ll*(L-positions[i]); if(i+K < N)suf[i] += suf[i+K]; } sum = min(suf[0], pre[N-1]); if(N==K)sum=min(sum, (ll)L); for(int i=0; i<N-1; i++){ sum = min(sum, pre[i] + suf[i+1]); if(i+K+1<N)sum = min(sum, pre[i] + L + suf[i+1+K]); else sum = min(sum, pre[i] + L); } return sum; }
#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...