제출 #601907

#제출 시각아이디문제언어결과실행 시간메모리
601907Summers선물상자 (IOI15_boxes)C++14
70 / 100
531 ms336164 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; long long a[10000002]; long long delivery(int N, int K, int L, int p[]) { long long mid, i, ans=0; for(mid=0;mid<N;mid++) { if(p[mid]>L/2)break; } for(i=0;i<mid;i++) { a[i]=p[i]*2; if(i>=K)a[i]+=a[i-K]; } for(i=N-1;i>=mid;i--) { a[i]=(L-p[i])*2; if(N-i>K)a[i]+=a[i+K]; } ans=a[mid]+a[mid-1]; for(i=max((long long)(-1),mid-K);i<min((long long)N,mid);i++) { if(i!=-1)ans=min(ans, a[i]+a[i+K+1]+L); else ans=min(a[i+K+1]+L,ans); } 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...