Submission #101350

#TimeUsernameProblemLanguageResultExecution timeMemory
101350ansol4328Boxes with souvenirs (IOI15_boxes)C++11
100 / 100
617 ms242020 KiB
#include<vector> #include<algorithm> using namespace std; typedef long long ll; int m[10000005]; ll dp1[10000005], dp2[10000005]; ll delivery(int N, int K, int L, int *positions) { for(int i=N ; i>0 ; i--) m[i]=positions[i-1]; for(int i=1 ; i<=N ; i++) { if(i<K) dp1[i]=m[i]+min(m[i],L-m[i]); else dp1[i]=dp1[i-K]+m[i]+min(m[i],L-m[i]); } for(int i=N ; i>=1 ; i--) { if(N-i<K) dp2[i]=(L-m[i])+min(m[i],L-m[i]); else dp2[i]=dp2[i+K]+(L-m[i])+min(m[i],L-m[i]); } ll res=dp1[0]+dp2[1]; for(int i=1 ; i<=N ; i++) res=min(res,dp1[i]+dp2[i+1]); return res; }
#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...