Submission #1051183

#TimeUsernameProblemLanguageResultExecution timeMemory
1051183ArthuroWichBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms348 KiB
#include "boxes.h" #include<bits/stdc++.h> #define int long long int using namespace std; int delivery(int32_t n, int32_t k, int32_t l, int32_t P[]) { int ans = 0; deque<int> p; for (int i = 0; i < n; i++) { p.push_back(P[i]); } sort(p.begin(), p.end()); while(!p.empty()) { int a = 0, b = p.back(), co = k; a = p[min((int)k, (int)p.size())-1]; b = l-p[max(0LL, (int)p.size()-k)]; a += min(a, l-a); b += min(b, l-b); if (a < b) { ans += a; while(co-- && !p.empty()) { p.pop_front(); } } else { ans += b; while(co-- && !p.empty()) { p.pop_back(); } } } 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...