Submission #228472

#TimeUsernameProblemLanguageResultExecution timeMemory
228472cfalas선물상자 (IOI15_boxes)C++14
20 / 100
5 ms384 KiB
#include<bits/stdc++.h> using namespace std; #include "boxes.h" #define ll long long long long delivery(int N, int K, int L, int p[]) { if(K==1){ ll ans=0; for(int i=0;i<N;i++){ ans+=2*min(p[i],L-p[i]); } return ans; } ll minCW[N+1] = {}; ll minCCW[N+1] = {}; //int cntCW[N+1] = {}; for(int i=1;i<=N;i++){ if(i%K==1) minCW[i] = minCW[i-1] + 2*p[i-1]; else minCW[i] = minCW[i-1] + 2*(p[i-1]-p[i-2]); //cout<<minCW[i]<<" "; } //cout<<endl; for(int i=1;i<=N;i++){ if(i%K==1) minCCW[i] = minCCW[i-1] + 2*(L-p[N - i]); else minCCW[i] = minCCW[i-1] + 2*(-p[N-i]+p[N-i+1]); //cout<<minCCW[i]<<" "; } ll mina = (N+K-1)/K * L; //cout<<endl; for(int i=0;i<=N;i++){ //cout<<minCW[i] + minCCW[N-i]<<endl; mina = min(mina, minCW[i] + minCCW[N-i]); if(i+K<=N) mina = min(mina, minCW[i] + L + minCCW[N-K-i]); } return mina; }
#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...