제출 #228470

#제출 시각아이디문제언어결과실행 시간메모리
228470cfalasBoxes with souvenirs (IOI15_boxes)C++14
10 / 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[]) { 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...