Submission #1304623

#TimeUsernameProblemLanguageResultExecution timeMemory
1304623vlomaczkA Difficult(y) Choice (BOI21_books)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> typedef long long ll; using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; void solve(int N, int K, ll A, int S) { ll lo=1, hi=N; while(lo < hi) { ll mid = (lo+hi)/2; if(skim(mid) < A) lo = mid + 1; else hi = mid; } if(lo < K) { impossible(); return; } if(lo < K) impossible(); vector<ll> val, idx; for(ll i=1; i<=K; ++i) { val.push_back(skim(i)); idx.push_back(i); } for(ll i=max(K, lo-K)+1; i<=lo; ++i) { val.push_back(skim(i)); idx.push_back(i); } ll suma = skim(lo); for(ll i=0; i<K-1; ++i) suma += val[i]; if(A<=suma && suma<=2*A) { vector<int> ans = {lo}; for(ll i=1; i<K; ++i) ans.push_back(i); answer(ans); } suma = 0; for(ll i=0; i<K; ++i) suma += val[i]; if(A<=suma && suma<=2*A) { vector<int> ans; for(ll j=0; j<K; ++j) ans.push_back(idx[j]); answer(ans); } for(ll i=K; i<val.size(); ++i) { suma -= val[i-K]; suma += val[i]; if(A<=suma && suma<=2*A) { vector<int> ans; for(ll j=i-K; j<i; ++j) ans.push_back(idx[j]); answer(ans); } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:29:21: error: no matching function for call to 'max(int&, ll)'
   29 |         for(ll i=max(K, lo-K)+1; i<=lo; ++i) {
      |                  ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from books.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
books.cpp:29:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   29 |         for(ll i=max(K, lo-K)+1; i<=lo; ++i) {
      |                  ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
books.cpp:29:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   29 |         for(ll i=max(K, lo-K)+1; i<=lo; ++i) {
      |                  ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
books.cpp:29:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |         for(ll i=max(K, lo-K)+1; i<=lo; ++i) {
      |                  ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
books.cpp:29:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |         for(ll i=max(K, lo-K)+1; i<=lo; ++i) {
      |                  ~~~^~~~~~~~~
books.cpp:36:36: warning: narrowing conversion of 'lo' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   36 |                 vector<int> ans = {lo};
      |                                    ^~
books.cpp:36:36: warning: narrowing conversion of 'lo' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]