Submission #93476

#TimeUsernameProblemLanguageResultExecution timeMemory
93476tincamateiBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
12 ms504 KiB
#include <bits/stdc++.h> #include "boxes.h" const int MAX_N = 10000000; long long pref[1+MAX_N], suff[1+MAX_N]; long long cost(int i, int j, int l, int k, int n) { return pref[i] + suff[j] + (long long)(n - i - j + k - 1) / k * l; } long long delivery(int n, int k, int l, int p[]) { long long rez = 1LL << 60; if(n > 1000) return 0LL; for(int i = 1; i <= n; ++i) { if(i - k >= 0) pref[i] = pref[i - k]; pref[i] = pref[i] + p[i - 1] * 2; } for(int i = 1; i <= n; ++i) { if(i - k >= 0) suff[i] = suff[i - k]; suff[i] = suff[i] + (l - p[n - i]) * 2; } int lastup = n; for(int i = 0; i <= n; ++i) { lastup = std::max(lastup, n - i); while(lastup > 0 && cost(i, lastup - 1, l, k, n) <= cost(i, lastup, l, k, n)) --lastup; rez = std::min(rez, cost(i, lastup, l, k, n)); } return rez; }
#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...