Submission #1120946

#TimeUsernameProblemLanguageResultExecution timeMemory
1120946SalihSahinBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
2069 ms37476 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> pos(N); for(int i = 0; i < N; i++){ pos[i] = p[i]; } vector<long long> dpl(N+1), dpr(N+1); for(int i = 1; i <= N; i++){ if(i < K) dpl[i] = pos[i-1] * 2; else dpl[i] = dpl[i - K] + pos[i-1] * 2; } for(int i = 1; i <= N; i++){ if(i < K) dpr[i] = (L - pos[N-i]) * 2; else dpr[i] = dpr[i - K] + (L - pos[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; long long 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...