Submission #134722

#TimeUsernameProblemLanguageResultExecution timeMemory
134722BoxworldBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
466 ms68060 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]){ int m=-1; long long ans=0; for (int i=0;i<N;i++)if (p[i]*2<L)m=i; for (int i=m;i>=0;i-=K)ans+=p[i]*2; for (int i=m+1;i<N;i+=K)ans+=(L-p[i])*2; if (m==-1||m==N-1)return ans; for (int t=0;t<K;t++){ // printf("Case:%d\n",t); long long ans1=0; int l=0,r=t; for (;;){ if (r<=m)ans1+=2*p[r]; if (l<=m&&r>m)ans1+=L; if (l>m)ans1+=2*(L-p[l]); // printf("l=%d r=%d ans=%d\n",l,r,ans1); if (r==N-1)break; l=r+1;r+=K; if (r>N-1)r=N-1; } ans=min(ans,ans1); } 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...