제출 #414038

#제출 시각아이디문제언어결과실행 시간메모리
414038TLP39선물상자 (IOI15_boxes)C++14
25 / 100
1 ms332 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; typedef long long int ll; int n,k,l; int cl=1,ch=1; ll dpl[10000001]={},dph[10000001]={}; long long delivery(int N, int K, int L, int p[]) { n=N; k=K; l=L; for(int i=0;i<n;i++) { if(p[i]==0) continue; if(p[i]<=l/2) { dpl[cl]=(ll)p[i]; dpl[cl]+=(cl>=k? dpl[cl-k]:0); cl++; } else { dph[ch]=(ll)(l-p[i]); ch++; } } ll temp; for(int i=1;i<(ch+1)/2;i++) { temp=dph[i]; dph[i]=dph[ch-i]; dph[ch-i]=temp; } for(int i=k;i<ch;i++) { dph[i]+=dph[i-k]; } ll ans=2*(dph[ch-1]+dpl[cl-1]); for(int i=0;i<=k;i++) { if(i>ch-1 || k-i>cl-1) continue; ans=min(ans,(ll)l+2*(dph[ch-1-i]+dpl[cl-1-(k-i)])); } 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...