Submission #725798

#TimeUsernameProblemLanguageResultExecution timeMemory
725798TheSahibBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms304 KiB
#include "boxes.h" #include <bits/stdc++.h> #define ll long long using namespace std; deque<int> q; ll delivery(int N, int K, int L, int p[]) { for (int i = 0; i < N; i++) { if(p[i] == 0) continue; q.push_back(p[i]); } ll ans = 0; while(!q.empty()){ K = min(K, int(q.size())); int d1 = q[K - 1]; int d2 = L - q[q.size() - K]; if(d1 > L / 2) d1 = L; else d1 *= 2; if(d2 > L / 2) d2 = L; else d2 *= 2; if(d1 <= d2){ for (int i = 0; i < K; i++) { q.pop_front(); } ans += d1; } else{ for (int i = 0; i < K; i++) { q.pop_back(); } ans += d2; } } 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...