제출 #996317

#제출 시각아이디문제언어결과실행 시간메모리
996317Alfraganus선물상자 (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...