Submission #621224

#TimeUsernameProblemLanguageResultExecution timeMemory
621224M_WBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms212 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; long long delivery(int N, int K, int L, int p[]) { int cnt = 1, mid = (L + 1) >> 1; long long ans = 0; int i = 0; while(i < N && p[i] == 0) i++; if(i == N) return 0; int st = p[i]; for(; i < N; i++){ if(cnt > K){ int ed = p[i - 1]; ans += (ed - st) * 1ll; if(st < mid) ans += (st * 1ll); else ans += ((L - st) * 1ll); if(ed < mid) ans += (ed * 1ll); else ans += ((L - ed) * 1ll); // printf("ans = %lld at %d\n", ans, i); cnt = 1; st = p[i]; } cnt++; } int ed = p[N - 1]; ans += (ed - st) * 1ll; // printf("%d %d\n", st, ed); if(st < mid) ans += (st * 1ll); else ans += ((L - st) * 1ll); if(ed < mid) ans += (ed * 1ll); else ans += ((L - ed) * 1ll); 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...