Submission #209358

#TimeUsernameProblemLanguageResultExecution timeMemory
209358autumn_eelBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
5 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; ll solve(int N,int K,int L,int p[]){ int s=0; while(s<N&&p[s]==0)s++; ll res=0; while(s<N){ int g=min(N-1,s+K-1); res+=min(p[s],L-p[s]);res+=min(p[g],L-p[g]);res+=abs(p[s]-p[g]); s=g+1; } return res; } long long delivery(int N, int K, int L, int p[]) { ll res1=solve(N,K,L,p); rep(i,N)p[i]=(L-p[i])%L; reverse(p,p+N); ll res2=solve(N,K,L,p); return min(res1,res2); }
#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...