Submission #402441

#TimeUsernameProblemLanguageResultExecution timeMemory
402441monus1042Boxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms204 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 answer = 0; for (int i=0; i<N; i++){ answer = answer + min(p[i],L-p[i])*2; } if (K==1) return answer; answer = 0; if (L==1) return answer; int mxd = L/2; int cnt = 0, cntright = 0; for (int i=0; i<N; i++){ if (p[i] <= mxd) cnt++; if ((p[i] == 0 || p[i] >= mxd+1) && N%2==1) cntright++; else if ((p[i] == 0 || p[i] >= mxd) && N%2==0) cntright++; } if (cnt == N) return 2LL*p[N-1]; if (cntright == N) return 2LL*(L-p[0]); answer = L; ll maxleft, maxright; maxleft = maxright = 0; for (int i=0; i<N; i++){ if (p[i] <= mxd){ maxleft = max(maxleft,(ll)p[i]); }else{ maxright = max(maxright, (ll)L-p[i]); } } ll answer2 = maxleft*2LL + maxright*2LL; answer = min(answer, answer2); return answer; }
#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...