제출 #996322

#제출 시각아이디문제언어결과실행 시간메모리
996322Alfraganus선물상자 (IOI15_boxes)C++17
10 / 100
1 ms432 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 ++) if(p[i] != 0) dq.push_back(p[i]); ll ans = 0; auto get = [&](ll x){return min(x, l - x);}; while(dq.size() > 0){ ll clock = dq[min((int)dq.size() - 1, k - 1)] + get(dq[min((int)dq.size() - 1, k - 1)]); ll counterclock = l - dq[max(0, (int)dq.size() - k)] + get(dq[max(0, (int)dq.size() - k)]); int sz = (int)dq.size(); if(clock < counterclock){ ans += clock; for(int i = 0; i < min(sz, k); i ++) dq.pop_front(); } else{ ans += counterclock; for(int i = 0; i < min(sz, 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...