Submission #209364

#TimeUsernameProblemLanguageResultExecution timeMemory
209364autumn_eelBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
5 ms256 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){ 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[]) { return (ll)min(p[0],L-p[0])+(ll)min(p[N-1],L-p[N-1])+(ll)min(p[N-1]-p[0],p[0]+N-p[N-1]); //~ int s=0; //~ while(s<N&&p[s]==0)s++; //~ ll res1=solve(N,K,L,p,s); //~ return res1; //~ for(int i=s;i<N;i++)p[i]=L-p[i]; //~ reverse(p+s,p+N); //~ ll res2=solve(N,K,L,p,s); //~ return min(res1,res2); }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:31: warning: unused parameter 'K' [-Wunused-parameter]
 long long delivery(int N, int K, int L, int p[]) {
                               ^
#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...