Submission #1033903

#TimeUsernameProblemLanguageResultExecution timeMemory
1033903fv3Boxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms440 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll delivery(int N_, int K_, int L_, int p[]) { ll L = L_; ll N = N_; ll K = K_; deque<ll> v(N); for (int i = 0; i < N; i++) v[i] = p[i]; sort(v.begin(), v.end()); ll res = 0; while (v.size()) { ll indexLeft = max((ll)v.size() - K, 0ll); ll indexRight = min((ll)v.size() - 1, K - 1); if (v[indexLeft] > L / 2) { res += (L - v[indexLeft]) * 2; for (int i = 0; i < K && v.size(); i++) v.pop_back(); } else if (v[indexRight] <= L / 2) { res += v[indexLeft] * 2; for (int i = 0; i < K && v.size(); i++) v.pop_front(); } else { res += L * ((v.size() + K - 1) / K); break; } } return res; }
#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...