Submission #691752

#TimeUsernameProblemLanguageResultExecution timeMemory
691752zeroesandonesBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
2072 ms340 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long; using pi = pair<ll, ll>; using vi = vector<ll>; #define pb emplace_back // for i from 1 to K, go till p[l + i] and return and reduce l to l + i + 1 // similarly for r, go till p[r - i] and return and reduce r to r - i - 1 ll calc(int l, int r, int n, int k, int L, int p[]) { if(r < l) return 0; ll ans = LLONG_MAX; ll sum = 0; ll last = 0; for(int i = 0; i < k; ++i) { if(l + i >= n) break; sum += 2 * (p[l + i] - last); last = p[l + i]; ans = min(ans, sum + calc(l + i + 1, r, n, k, L, p)); } sum = 0; last = L; for(int i = 0; i < k; ++i) { if(r - i < 0) break; sum += 2 * (last - p[r - i]); last = p[r - i]; ans = min(ans, sum + calc(l, r - i - 1, n, k, L, p)); } return ans; } ll delivery(int N, int K, int L, int p[]) { ll ans = calc(0, N - 1, N, K, L, p); 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...