Submission #791970

#TimeUsernameProblemLanguageResultExecution timeMemory
791970JosiaBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
2078 ms212 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define int int64_t long long delivery(signed N, signed K, signed L, signed p[]) { vector<int> left, right; for (int i = 0; i<N; i++) { if (p[i] <= L/2) left.push_back(p[i]); else right.push_back(L-p[i]); } sort(left.begin(), left.end()); sort(right.begin(), right.end()); auto leftO = left; auto rightO = right; long long res = 0; while (left.size() && right.size() && (left.back() + right.back())*2 > L) { for (int i = 0; i<K; i++) { if ((left.size() && right.empty()) || (left.size() && left.back() > right.back())) { left.pop_back(); } else if (right.size()) { right.pop_back(); } } } while (left.size()) { res += left.back()*2; for (int i = 0; i<K; i++) { if (left.size()) left.pop_back(); } } while (right.size()) { res += right.back()*2; for (int i = 0; i<K; i++) { if (right.size()) right.pop_back(); } } }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:50:1: warning: no return statement in function returning non-void [-Wreturn-type]
   50 | }
      | ^
#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...