Submission #976775

#TimeUsernameProblemLanguageResultExecution timeMemory
976775AmaarsaaBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long ; ll delivery(ll N, ll K, ll L, ll 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] == 0) continue; if ( p[i] * 2 > L) { ard.push_back(p[i]); } else { if (p[i] * 2 < L) urd.push_back(p[i]); else cnt ++; } } ll Ard = 0, A = 0; ll Urd = 0, U = 0; ans = 0; reverse(ard.begin(), ard.end()); for (i = urd.size() - 1; i >= 0; i -= K) U += urd[i]; j = i + K; for (i = ard.size() - 1; i >= 0; i -= K) A += (L - ard[i]); r = i + K; for (i = K - 1; i < urd.size(); i += K) Urd += (urd[i]); for (i = K - 1; i < ard.size(); i += K) Ard += ( L - ard[i]); // cout << ans << endl; cnt_urd = j + 1; cnt_ard = r + 1; U *= 2; A *= 2; Urd *= 2; Ard*= 2; // cout << cnt_urd << " " << cnt_ard << endl; // cout << U << " " << A << endl; // cout << Urd << " " << Ard << endl; res = ((cnt_ard + cnt_urd + cnt + K - 1) / K) * L; res = res + Urd + Ard; // cout << res << endl; if ( cnt_ard != 0) { res = min(res, ((Urd + A+ ((cnt_urd + cnt + K - 1)/K) * L) )); } // cout << res << endl; if ( cnt_urd != 0) { res = min(res, (( U + Ard+ ((cnt_ard + cnt + K - 1)/K) * L) )); } // cout << res << endl; if ( cnt_ard != 0 && cnt_urd != 0) { res = min(res, ((A + U+ ((cnt + K - 1)/K) * L) )); } return res; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(ll, ll, ll, ll*)':
boxes.cpp:28: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]
   28 |  for (i = K - 1; i < urd.size(); i += K) Urd += (urd[i]);
      |                  ~~^~~~~~~~~~~~
boxes.cpp:29: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]
   29 |  for (i = K - 1; i < ard.size(); i += K) Ard += ( L - ard[i]);
      |                  ~~^~~~~~~~~~~~
boxes.cpp:7:5: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
    7 |  ll ans, cnt_ard, cnt_urd, res;
      |     ^~~
boxes.cpp:9:23: warning: unused variable 's' [-Wunused-variable]
    9 |  ll cnt = 0, i, j, r, s;
      |                       ^
/usr/bin/ld: /tmp/ccdmVAjM.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status