Submission #1120771

#TimeUsernameProblemLanguageResultExecution timeMemory
1120771SalihSahinBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; #include "boxes.h" long long delivery(int N, int K, int L, int p[]) { vector<int> pos(N); for(int i = 0; i < N; i++){ pos[i] = p[i]; } vector<pair<int, long long> > lop, rop; // kac kisiyi, ne kadar surede lop.pb({0, 0LL}), rop.pb({0, 0LL}); int ind = N-1; for(int i = 1; i <= N/K; i++){ int wh = K; while(wh >= 1 && ind >= 1 && pos[ind-1] >= (N + 1)/2){ wh--; ind--; } int new_taken = ((N-1) - ind) - rop.back().first; long long op = ((N-1) - pos[ind] + 1) * 2 + rop.back().second; rop.pb({new_taken, op}); } ind = 0; for(int i = 1; i <= N/K; i++){ int wh = K; while(wh >= 1 && ind < N-1 && pos[ind+1] <= N/2){ wh--; ind++; } int new_taken = ind - rop.back().first; long long op = pos[ind] * 2 + rop.back().second; lop.pb({new_taken, op}); } long long ans = inf; for(int l = 0; l < lop.size(); l++){ for(int r = 0; r < rop.size(); r++){ int rem = N - lop[l].first - rop[r].first; long long calc = lop[l].second + rop[r].second + ((rem + K - 1)/K) * L; ans = min(ans, calc); } } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:40:21: error: 'inf' was not declared in this scope; did you mean 'ind'?
   40 |     long long ans = inf;
      |                     ^~~
      |                     ind
boxes.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int l = 0; l < lop.size(); l++){
      |                    ~~^~~~~~~~~~~~
boxes.cpp:42:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(int r = 0; r < rop.size(); r++){
      |                        ~~^~~~~~~~~~~~