제출 #119718

#제출 시각아이디문제언어결과실행 시간메모리
119718nxteru선물상자 (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=0;i<n;i++){ q[i]=p[i]; if(m==-1&&p[i]>l/2)m=i; } if(m==-1)m=n; for(int i=m-1;i>=0;i-=k){ x[0]+=q[i]*2; } int r=0; for(int i=m-2;i>=0;i--){ x[r%k+1]-=(q[i+1]-q[i])*2; r++; } for(int i=1;i<=k;i++)x[i]+=x[i-1]; for(int i=m;i<n;i+=k){ y[0]+=(n-q[i])*2; } r=0; for(int i=m+1;i<n;i++){ y[r%k+1]-=(q[i]-q[i-1])*2; 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(n)+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...