Submission #147140

#TimeUsernameProblemLanguageResultExecution timeMemory
147140nandonathanielBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
447 ms18168 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long LL; const LL INF=1e18; LL dp[1005]; LL dist(LL x,LL y,LL mod){ return min((y-x+mod)%mod,(x-y+mod)%mod); } LL cost(LL a,LL b,LL mod){ return dist(a,0,mod)+(b-a+mod)%mod+dist(b,0,mod); } LL delivery(int N, int K, int L, int p[]) { dp[0]=0; for(LL i=1;i<=N;i++){ dp[i]=INF; for(LL j=max(i-K,0LL);j<=i-1;j++){ dp[i]=min(dp[i],dp[j]+cost(p[j],p[i-1],L)); } } return dp[N]; }
#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...