Submission #1008002

#TimeUsernameProblemLanguageResultExecution timeMemory
1008002MardonbekhazratovBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms448 KiB
#include "boxes.h" #include<bits/stdc++.h> #define ll long long using namespace std; long long delivery(int N, int K, int L, int p[]) { multiset<int>left,right; for(int i=0;i<N;i++){ left.insert(p[i]); right.insert(L-p[i]); } ll ans=0; while(!left.empty()){ int k=K; ll sl=0,sr=0; vector<int>l,r; while(!left.empty() && k--){ l.push_back(*left.begin()); r.push_back(*right.begin()); right.erase(right.begin()); left.erase(left.begin()); } sl+=min(2*l.back(),L); sr+=min(2*r.back(),L); if(sl<sr){ ans+=sl; for(int x:r) right.insert(x); for(int x:l){ right.erase(right.find(L-x)); } } else{ ans+=sr; for(int x:l) left.insert(x); for(int x:r){ left.erase(left.find(L-x)); } } } 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...