제출 #600400

#제출 시각아이디문제언어결과실행 시간메모리
600400Bench0310선물상자 (IOI15_boxes)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; const int N=10000000; ll one[N]; ll two[N]; ll delivery(int n,int k,int l,int p[]) { for(int i=0;i<n;i++) if(p[i]==0) p[i]=l; sort(p,p+n); while(n>=1&&p[n-1]==l) n--; if(n==0) return 0; for(int i=0;i<n;i++) one[i]=(i>=k?one[i-k]:0)+2*p[i]; for(int i=n-1;i>=0;i--) two[i]=(i+k<n?two[i+k]:0)+2*(l-p[i]); ll res=min(one[n-1],two[0]); if(n<=k) res=min(res,ll(l)); for(int i=0;i+k-1<n;i++) res=min(res,l+(i-1>=0?one[i-1]:0)+(i+k<n?two[i+k]:0)); return res; }
#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...