제출 #800691

#제출 시각아이디문제언어결과실행 시간메모리
800691firewater선물상자 (IOI15_boxes)C++14
20 / 100
1 ms288 KiB
#include "boxes.h" #include <stdio.h> #include <stdlib.h> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long using namespace std; #define N 100100 ll n,k,m,ans,x,now1,now2,nn,a[N],b[N]; long long delivery(int NN, int K, int L, int ppp[]) { nn=NN; k=K; for(ll i=1;i<=nn;++i){ x=ppp[i-1]; if(x<L-x)a[++n]=x; else b[++m]=L-x; } sort(a+1,a+1+n); sort(b+1,b+1+m); now1=now2=0; while(n-now1>=k){ now1=now1+k; ans+=a[now1]*2; } while(m-now2>=k){ now2=now2+k; ans+=b[now2]*2; } if(now1>=n&&now2>=m)return ans; if(now1>=n)return ans+b[m]*2; if(now2>=m)return ans+a[n]*2; x=n-now1+m-now2; if(x<=k){ ans+=min(a[n]*2+b[m]*2,1ll*L); } else{ ans+=min(min(1ll*L*2,a[n]*2+b[m]*2),min(a[now1+(x-k)]*2+m,b[now2+(x-k)]*2+m)); } 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...