Submission #976746

#TimeUsernameProblemLanguageResultExecution timeMemory
976746AmaarsaaBoxes with souvenirs (IOI15_boxes)C++14
20 / 100
1 ms600 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long ; ll delivery(int N, int K, int L, int p[]) { ll ans, cnt_ard, cnt_urd, res; vector < ll > ard, urd; ll cnt = 0, i, j, r, s; for (i = 0; i < N; i ++) { if ( p[i] * 2 > L) { ard.push_back(p[i]); } else { if (p[i] * 2 < L) urd.push_back(p[i]); else cnt ++; } } ans = 0; for (i = K - 1; i < urd.size(); i += K) { ans += urd[i]; } j = i - K + 1; reverse(ard.begin(), ard.end()); for (i = K - 1; i < ard.size(); i += K) { ans += (L - ard[i]); } r = i - K + 1; ans *= 2; cnt_urd = urd.size() - j; cnt_ard = ard.size() - r; res = ((cnt_ard + cnt_urd + cnt + K - 1) / K) * L; if ( cnt_ard != 0) { res = min(res, (((L - ard.back()) * 2) + ((cnt_urd + cnt + K - 1)/K) * L) ); } if ( cnt_urd != 0) { res = min(res, (((urd.back()) * 2) + ((cnt_ard + cnt + K - 1)/K) * L) ); } if ( cnt_ard != 0 && cnt_urd != 0) { res = min(res, (((L - ard.back()) * 2) + (urd.back() * 2)+ ((cnt + K - 1)/K) * L) ); } return res + ans; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:20:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (i = K - 1; i < urd.size(); i += K) {
      |                  ~~^~~~~~~~~~~~
boxes.cpp:25:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (i = K - 1; i < ard.size(); i += K) {
      |                  ~~^~~~~~~~~~~~
boxes.cpp:9:23: warning: unused variable 's' [-Wunused-variable]
    9 |  ll cnt = 0, i, j, r, s;
      |                       ^
#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...