Submission #1005999

#TimeUsernameProblemLanguageResultExecution timeMemory
1005999LudisseyBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms436 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=1e9; int sumNOTFULL=0; int lmt=N; vector<int> prf1(sz(a)+1,0); vector<int> prf2(sz(a)+1,0); lmt=sz(a); for (int i = 0; i < sz(a); i++) { if(a[i]>L/2) { lmt=i; break; } } for (int i = 0; i < N; i++) { if(i<K) prf1[i]=a[i]*2; else prf1[i]=a[i]*2+prf1[i-K]; } for (int i = sz(a)-1; i >= 0; i--) { if(i>=sz(a)-K) prf2[i]=(L-a[i])*2; else prf2[i]=(L-a[i])*2+prf2[i+K]; } sumFULL=min(sumFULL, L+prf2[K]); for (int i = 0; i < sz(a)-K; i++) sumFULL=min(sumFULL, L+prf1[i]+prf2[i+K+1]); for (int i = lmt-1; i >= 0; i-=K) sumNOTFULL+=a[i]*2; for (int i = lmt; i < sz(a); i+=K) sumNOTFULL+=(L-a[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...