Submission #806770

#TimeUsernameProblemLanguageResultExecution timeMemory
806770IvanJBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
516 ms293652 KiB
#include "boxes.h" #include<bits/stdc++.h> #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 1e7 + 5; ll l[maxn], r[maxn]; ll delivery(int N, int K, int L, int p[]) { for(int i = 1;i <= N;i++) { l[i] = 2 * p[i - 1]; r[i] = 2 * (L - p[N - i]); if(i >= K) l[i] += l[i - K], r[i] += r[i - K]; } ll ans = 1e18; for(int i = 0;i <= N;i++) ans = min(ans, l[i] + r[N - i]); for(int i = 0;i <= N - K;i++) ans = min(ans, l[i] + r[N - i - K] + (ll)L); 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...