Submission #728594

#TimeUsernameProblemLanguageResultExecution timeMemory
728594AndrijaMBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; long long delivery(int n, int k, int L, int p[]) { long long ans=0; long long l=-1; long long r=n; while(true) { if(l>=r)break; long long mi1=0; long long a=l+k; if(a<=r) { mi1=min(2*p[a], L); } long long mi2=0; long long b=r-k; if(b>=l) { mi2=min(2*(L-p[b]), L); } if(mi1==0 && mi2==0) { break; } if(mi1<=mi2) { ans+=mi1; l=a+1; } else if(mi1>mi2) { ans+=mi2; r=b-1; } } if(l!=r) { if(l==-1) { l++; } if(r==n) { r--; } ans+=min(L,min(2*(L-p[l]),2*p[r])); } 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...