Submission #862075

#TimeUsernameProblemLanguageResultExecution timeMemory
862075culver0412Boxes with souvenirs (IOI15_boxes)C++17
100 / 100
735 ms450412 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { sort(p,p+N); long long arr[N],brr[N],crr[N],drr[N]; int st=0; while(p[st]==0){ st++; if(st==N){ return 0; } } for(int i=st;i<N;i++){ arr[i]=min(p[i]*2,L); crr[i]=arr[i]; if(i-K>=st){ crr[i]+=crr[i-K]; } } for(int i=N-1;i>=st;i--){ brr[i]=min((L-p[i])*2,L); drr[i]=brr[i]; if(i+K<=N-1){ drr[i]+=drr[i+K]; } } long long ans=min(drr[st],crr[N-1]); //cout << drr[st] << '\n'; for(int i=st;i<N-1;i++){ //cout << crr[i]+drr[i+1] << '\n'; ans=min(ans,crr[i]+drr[i+1]); } //cout << crr[N-1] << '\n'; 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...