Submission #172084

#TimeUsernameProblemLanguageResultExecution timeMemory
172084gs18103Boxes with souvenirs (IOI15_boxes)C++14
10 / 100
2 ms504 KiB
#include "boxes.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define em emplace #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; const int MAX = 101010; const int INF = 1e9; const ll LINF = 1e18; long long delivery(int N, int K, int L, int p[]) { vector <int> l, r; for(int i = 0; i < N; i++) { if(p[i] <= L / 2) l.eb(p[i]); else r.eb(L-p[i]); } ll ans = 0; while(!l.empty() && !r.empty() && l.back() + r.back() >= L) { ans += L; for(int i = 0; i < K; i++) { if(l.empty()) r.pop_back(); else if(r.empty()) l.pop_back(); else if(l.back() > r.back()) l.pop_back(); else r.pop_back(); } } while(!l.empty()) { ans += 2 * l.back(); for(int i = 0; i < K; i++) if(!l.empty()) l.pop_back(); } while(!r.empty()) { ans += 2 * r.back(); for(int i = 0; i < K; i++) if(!r.empty()) r.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...