Submission #963552

#TimeUsernameProblemLanguageResultExecution timeMemory
963552Hugo1729Boxes with souvenirs (IOI15_boxes)C++11
100 / 100
462 ms294012 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; ll delivery(int N, int K, int L, int p[]){ vector<ll> left(N+1,0),right(N+1,0); for(int i=0;i<N;i++){ if(i<K){ left[i+1]=min(p[i]*2,L); right[i+1]=min((L-p[N-1-i])*2,L); }else{ left[i+1]=min(p[i]*2,L)+left[i+1-K]; right[i+1]=min((L-p[N-1-i])*2,L)+right[i+1-K]; } } // for(int i=0;i<N;i++)p[i]=L-p[i]; // for(int i=0;i<N;i++){ // if(i<K){ // right[i+1]=min(p[i]*2,L); // }else{ // right[i+1]=min(p[i]*2,L)+right[i+1-K]; // } // } ll ans=LLONG_MAX; for(int i=0;i<N+1;i++)ans=min(ans,left[i]+right[N-i]); // for(int i=0;i<N+1;i++)cout << left[i] << ' '; // cout << '\n'; // for(int i=0;i<N+1;i++)cout << right[i] << ' '; // cout << '\n'; 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...