Submission #101348

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