Submission #147599

#TimeUsernameProblemLanguageResultExecution timeMemory
147599nandonathanielBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long LL; const LL INF=1e18; 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[]) { return 0; LL sisa=N%K,ans=INF; for(LL i=0;i<=sisa;i++){ //i di kiri, sisa-i di kanan LL ret=0; if(i!=0)ret+=cost(p[0],p[i-1],L); for(LL j=1;j<=N/K;j++)ret+=cost(p[i+(j-1)*K],p[i+j*K-1],L); if(sisa-i!=0)ret+=cost(p[N-sisa+i],p[N-1],L); ans=min(ans,ret); } 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...