Submission #674834

#TimeUsernameProblemLanguageResultExecution timeMemory
674834benjaminkleynBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms240 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; ll delivery(int n, int k, int l, int p[]) { vector<ll> L, R; for (int i = 0; i < n; i++) if (l - p[i] < p[i]) L.push_back(l - p[i]); else R.push_back(p[i]); sort(L.rbegin(), L.rend()); sort(R.rbegin(), R.rend()); ll ans = 0; while (L.size() >= k) { for (int i = 0; i < k - 1; i++) L.pop_back(); ans += 2 * L.back(); L.pop_back(); } while (R.size() >= k) { for (int i = 0; i < k - 1; i++) R.pop_back(); ans += 2 * R.back(); R.pop_back(); } if (L.size() == 0) ans += 2 * R.back(); else if (R.size() == 0) ans += 2 * L.back(); else if (L.size() + R.size() <= k) ans += l; else ans += l + min(R[k - L.size()], L[k - R.size()]); return ans; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:20:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     while (L.size() >= k)
      |            ~~~~~~~~~^~~~
boxes.cpp:27:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     while (R.size() >= k)
      |            ~~~~~~~~~^~~~
boxes.cpp:38:34: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |     else if (L.size() + R.size() <= k)
      |              ~~~~~~~~~~~~~~~~~~~~^~~~
#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...