Submission #787766

#TimeUsernameProblemLanguageResultExecution timeMemory
787766fabijan_cikacA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; #define pp pair<int, ll> #define F first #define S second #define ll long long #define pb push_back void solve(int N, int K, ll A, int S){ int l = 1, r = N; while (l < r){ int mid = (l + r - 1) / 2; if (skim(mid) >= A) r = mid; else l = mid + 1; } vector<pp> v; for (int i = 1; i <= l; ++i){ if (i <= k || i >= l - k + 1) v.pb({i, skim(i)}); } for (int i = 0; i < (1 << (int)(v.size())); ++i){ if (__builtin_popcount(i) != K) continue; ll sum = 0; for (int j = 0; j < v.size(); ++j){ if (i & (1 << j)) sum += v[j].S; } if (sum >= A && sum <= 2 * A){ vector<int> ans; for (int j = 0; j < v.size(); ++j){ if (i & (1 << j)) ans.pb(v[j].F); } sort(ans.begin(), ans.end()); answer(ans); } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:22:16: error: 'k' was not declared in this scope
   22 |       if (i <= k || i >= l - k + 1)
      |                ^
books.cpp:29:27: 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]
   29 |         for (int j = 0; j < v.size(); ++j){
      |                         ~~^~~~~~~~~~
books.cpp:34:31: 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]
   34 |             for (int j = 0; j < v.size(); ++j){
      |                             ~~^~~~~~~~~~