제출 #1215685

#제출 시각아이디문제언어결과실행 시간메모리
1215685byunjaewooBoxes with souvenirs (IOI15_boxes)C++20
50 / 100
23 ms4164 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll=long long; ll delivery(int N, int K, int L, int p[]) { int l=0, r=0, t=-1; ll ans=0, ans2=0; for(int i=0; i<N; i++) if(p[i]<=L/2) t=i; for(int i=K-1; i<=t; i+=K) ans+=2*p[i]; for(int i=N-K; i>t; i-=K) ans+=2*(L-p[i]); for(int i=t; i>=0; i-=K) ans2+=2*p[i]; for(int i=t+1; i<N; i+=K) ans2+=2*(L-p[i]); l=(t+1)%K, r=(N-t-1)%K; if(!l && !r); if(!l) ans+=2*(L-p[t+1]); else if(!r) ans+=2*p[t]; else { ll ans2=min(L*((l+r+K-1)/K), 2*p[t]+2*(L-p[t+1])); if(l+r>K) { ans2=min(ans2, (ll)L+2*p[t-(K-r)]); ans2=min(ans2, (ll)L+2*(L-p[t+1+(K-l)])); for(int i=t-l+1; i<=t; i++) if(t+1+K-(t-i)<N) ans2=min(ans2, (ll)L+2*p[i]+2*(L-p[t+1+K-(t-i)])); } ans+=ans2; } return min(ans, ans2); }
#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...