제출 #60708

#제출 시각아이디문제언어결과실행 시간메모리
60708Eae02선물상자 (IOI15_boxes)C++14
10 / 100
2 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> #include <set> long long delivery(int numTeams, int capacity, int numSections, int p[]) { std::sort(p, p + numTeams); auto DistTo0 = [&] (int x) { return std::min(x, numSections - x); }; int done = 0; long long sec = 0; while (done < numTeams) { int boxes = capacity; //std::cout << "MO " << DistTo0(pos) << std::endl; sec += DistTo0(p[done]); while (true) { int oldPos = p[done]; int numToGive = 0; while (numToGive < boxes && p[done + numToGive] == oldPos) numToGive++; done += numToGive; boxes -= numToGive; if (boxes <= 0 || done >= numTeams) { //std::cout << "MB " << std::abs(p[done] - oldPos) << std::endl; sec += DistTo0(oldPos); break; } //std::cout << "MS " << std::abs(p[done] - oldPos) << std::endl; sec += std::abs(p[done] - oldPos); } } return sec; }
#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...