Submission #20889

#TimeUsernameProblemLanguageResultExecution timeMemory
20889baneling100Boxes with souvenirs (IOI15_boxes)C++98
10 / 100
2 ms376 KiB
#include "boxes.h" #include <algorithm> using namespace std; long long Res1, Res2; long long delivery(int N, int K, int L, int p[]) { int i, s; for(i=0 ; i<N ; i++) if(p[i]) break; s=i; while(i+K-1<N && p[i+K-1]<=L/2) { Res1+=2*p[i+K-1]; i+=K; } if(i<N && p[i]<=L/2) { Res1+=L; i+=K; } while(i<N) { Res1+=2*(L-p[i]); i+=K; } i=N-1; while(i-K+1>=s && p[i-K+1]>=L/2) { Res2+=2*(L-p[i-K+1]); i-=K; } if(i>=s && p[i]>=L/2) { Res2+=L; i-=K; } while(i>=s) { Res2+=2*p[i]; i-=K; } return min(Res1,Res2); return 0; }
#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...