Submission #933447

#TimeUsernameProblemLanguageResultExecution timeMemory
933447AtabayRajabliA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; const long long sz = 1e5 + 5; long long q[sz]; long long get(long long x) { if(q[x])return q[x]; return q[x] = skim(x); } void solve(int n, int k, long long a, int s) { long long l = 1, r = n, ind = n + 1; while(l <= r) { long long m = (l + r) >> 1; if(get(m) >= a)r = m - 1, ind = m; else l = m + 1; } if(ind < k)impossible(); vector<long long> v; long long sum = 0; for(long long i = 1; i <= k; i++) { v.push_back(i); sum += get(i); } if(sum > 2 * a)impossible(); for(long long i = max(k + 1, ind - k + 1); i <= ind; i++) { v.push_back(i); } l = 0, r = k; for(long long i = 0; i + k < v.size(); i++) { if(a <= sum && sum <= a * 2)break; sum -= get(v[l]), l++; sum += get(v[r]), r++; } if(a <= sum && sum <= a * 2) { vector<int> ans; while(l < r)ans.push_back(v[l++]); answer(ans); } else impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:36:45: error: no matching function for call to 'max(int, long long int)'
   36 |     for(long long i = max(k + 1, ind - k + 1); i <= ind; i++)
      |                                             ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
books.cpp:36:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   36 |     for(long long i = max(k + 1, ind - k + 1); i <= ind; i++)
      |                                             ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
books.cpp:36:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   36 |     for(long long i = max(k + 1, ind - k + 1); i <= ind; i++)
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
books.cpp:36:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   36 |     for(long long i = max(k + 1, ind - k + 1); i <= ind; i++)
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
books.cpp:36:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   36 |     for(long long i = max(k + 1, ind - k + 1); i <= ind; i++)
      |                                             ^
books.cpp:42:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(long long i = 0; i + k < v.size(); i++)
      |                          ~~~~~~^~~~~~~~~~