제출 #119723

#제출 시각아이디문제언어결과실행 시간메모리
119723nxteru선물상자 (IOI15_boxes)C++14
0 / 100
2 ms384 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1000000000000000000 int n,k,l,m=-1; ll x[5000005],y[5000005],q[10000005],ans=INF; long long delivery(int N, int K, int L, int p[]) { n=N,k=K,l=L; for(int i=1;i<=n;i++){ q[i]=p[i]; if(m==-1&&p[i]>l/2)m=i; } q[n+1]=l; if(m==-1)m=n+1; n+=2; for(int i=m-1;i>=0;i-=k){ x[0]+=q[i]*2LL; } int r=0; for(int i=m-2;i>=0;i--){ x[r%k+1]-=(q[i+1]-q[i])*2LL; r++; } for(int i=1;i<=k;i++){ x[i]+=x[i-1]; } for(int i=m;i<n;i+=k){ y[0]+=(l-q[i])*2LL; } r=0; for(int i=m+1;i<n;i++){ y[r%k+1]-=(q[i]-q[i-1])*2LL; r++; } for(int i=1;i<=k;i++){ y[i]+=y[i-1]; } ans=x[0]+y[0]; for(int i=0;i<=k;i++){ ans=min(ans,ll(l)+x[i]+y[k-i]); } 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...