Submission #1004834

#TimeUsernameProblemLanguageResultExecution timeMemory
1004834LudisseyBoxes with souvenirs (IOI15_boxes)C++14
35 / 100
1 ms600 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define int long long #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() int N,K,L; int clst(int x){ if(x>L/2) x=L-x; return (x)*2; } long long delivery(signed _n, signed _k, signed _l, signed p[]) { N=_n; K=_k; L=_l; vector<int> a(N); vector<int> marked(N); for (int i = 0; i < N; i++) a[i]=p[i]; sort(a.begin(),a.end()); int sumFULL=L; int sumNOTFULL=0; int lmt=N; vector<pair<int,int>> res; vector<int> res2; vector<int> res3; for (int i = 0; i < N; i++) { res.push_back({abs(L-2*a[i]),i}); } sort(all(res)); for (int i = 0; i < sz(res); i++) { if(i<K) res3.push_back(res[i].second); else { res3.push_back(res[i].second); res2.push_back(res[i].second); } } sort(all(res2)); sort(all(res3)); lmt=sz(res2); for (int i = 0; i < sz(res2); i++) { if(a[res2[i]]>L/2) { lmt=i; break; } } for (int i = lmt-1; i >= 0; i-=K) sumFULL+=a[res2[i]]*2; for (int i = lmt; i < sz(res2); i+=K) sumFULL+=(L-a[res2[i]])*2; lmt=sz(res3); for (int i = 0; i < sz(res3); i++) { if(a[res3[i]]>L/2) { lmt=i; break; } } for (int i = lmt-1; i >= 0; i-=K) sumNOTFULL+=a[res3[i]]*2; for (int i = lmt; i < sz(res3); i+=K) sumNOTFULL+=(L-a[res3[i]])*2; return min(sumFULL,sumNOTFULL); }
#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...