Submission #217839

#TimeUsernameProblemLanguageResultExecution timeMemory
217839DavidDamianBoxes with souvenirs (IOI15_boxes)C++11
20 / 100
5 ms384 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; long long delivery(int N, int K, int L, int p[]) { ll total=0; int remaining=K; int a=0,b=N-1; int last=-1; while(a<=b){ ll distA; ll distB; int selected=0; if(remaining==K){ distA=min(p[a],L-p[a]); distB=min(p[b],L-p[b]); if(distA<=distB) selected=a; else selected=b; total+=(selected==a)? distA : distB; } else{ distA=min(abs(p[a]-p[last]),L-abs(p[a]-p[last])); distB=min(abs(p[b]-p[last]),L-abs(p[b]-p[last])); if(distA<=distB) selected=a; else selected=b; total+=(selected==a)? distA : distB; } remaining--; if(remaining==0 || a==b){ distA=min(p[a],L-p[a]); distB=min(p[b],L-p[b]); total+=(selected==a)? distA : distB; remaining=K; } last=selected; if(selected==a) a++; else b--; } return total; }
#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...