제출 #600389

#제출 시각아이디문제언어결과실행 시간메모리
600389Bench0310선물상자 (IOI15_boxes)C++17
50 / 100
84 ms13896 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; ll delivery(int n,int k,int l,int p[]) { sort(p,p+n); ll res=(1ll<<60); auto go=[&](int t) { ll now=0; int x=0; while(x<n&&p[x]==0) x++; while(x<n) { int y=min(n-1,x+k-1); if(p[y]<=l/2) now+=(2*p[y]); else if(p[x]>l/2) now+=(2*(l-p[x])); else if(t==0) now+=l; else if(t==1) { int a=x; while(p[a+1]<=l/2) a++; now+=(2*p[a]); x=a+1-k; } x+=k; } res=min(res,now); }; go(0); go(1); for(int i=0;i<n;i++) p[i]=(l-p[i])%l; sort(p,p+n); go(0); go(1); 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...