Submission #996317

#TimeUsernameProblemLanguageResultExecution timeMemory
996317AlfraganusBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; #define ll long long ll delivery(int n, int k, int l, int p[]) { deque<int> dq; for(int i = 0; i < n; i ++) dq.push_back(p[i]); ll ans = 0; auto get = [&](int x){return min(x, l - x);}; while(dq.size() > 0){ int clock = dq[min((int)dq.size() - 1, k - 1)] + get(dq[min((int)dq.size() - 1, k - 1)]); int counterclock = l - dq[max(0, (int)dq.size() - k)] + get(dq[max(0, (int)dq.size() - k)]); if(clock < counterclock){ ans += clock; for(int i = 0; i < min((int)dq.size(), k); i ++) dq.pop_front(); } else{ ans += counterclock; for(int i = 0; i < min((int)dq.size(), k); i ++) dq.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...