Submission #1120921

#TimeUsernameProblemLanguageResultExecution timeMemory
1120921SalihSahinBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2 ms336 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; #include "boxes.h" const long long inf = 1e18; long long delivery(int N, int K, int L, int p[]) { vector<long long> dpl(N+1), dpr(N+1); for(int i = 1; i <= N; i++){ if(i < K) dpl[i] = p[i-1] * 2; else dpl[i] = dpl[i - K] + p[i-1] * 2; } for(int i = N; i >= 1; i--){ if(i < K) dpr[N-i+1] = (L - p[N-i]) * 2; else dpr[N-i+1] = dpr[(N-i+1) - K] + (L - p[N-i]) * 2; } long long ans = inf; for(int l = 0; l <= N; l++){ for(int r = 0; r <= N; r++){ if(l + r > N) break; int rem = N - l - r; long long calc = dpl[l] + dpr[r] + ((rem + K - 1)/K) * L; ans = min(ans, calc); } } 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...