Submission #1224380

#TimeUsernameProblemLanguageResultExecution timeMemory
1224380KALARRYA Difficult(y) Choice (BOI21_books)C++20
Compilation error
0 ms0 KiB
//chockolateman #include<bits/stdc++.h> #include"books.h" using namespace std; long long a[100005]; void solve(int N,int K,long long A,int S) { long long l = 1; long long r = N; for(long long i = 1 ; i <= min(N,10) ; i++) a[i] = skim(i); long long sum_l = 0; vector<int> ret; for(long long i = 1 ; i <= K ; i++) sum_l += a[i]; if(sum_l > 2*A) impossible(); else if(A <= sum_l && sum_l <= 2*A) { for(long long i = 1 ; i <= K ; i++) ret.push_back(i); } else { while(l < r - 1) //searching for first val >= A { long long mid = (l + r + 1)/2; if(!a[mid]) a[mid] = skim(mid); if(a[mid] < A) l = mid + 1; else if(a[mid]) r = mid; } if(l==r-1) { if(!a[l]) a[l] = skim(l); if(a[l] >= A) r = l; } if(!a[r]) a[r] = skim(r); long long sum_temp = sum_l - a[K] + a[r]; if(sum_temp > 2*A) { r--; long long sum_r = 0; for(long long i = r ; i >= max(r - K + 1,1) ; i--) { if(!a[i]) a[i] = skim(i); sum_r += a[i]; } if(sum_r < A) impossible(); long long cur_sum = sum_l; long long pos = 0; for(long long j = 1 ; j <= K ; j++) { sum_l += a[r - j + 1] - a[K - j + 1]; if(A <= sum_l && sum_l <= 2*A) { pos = j; } } for(long long i = 1 ; i <= K - pos ; i++) ret.push_back(i); for(long long i = r - pos + 1 ; i <= r ; i++) ret.push_back(i); } else { for(long long i = 1 ; i < K ; i++) ret.push_back(i); ret.push_back(r); } } answer(ret); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:53:43: error: no matching function for call to 'max(long long int, int)'
   53 |             for(long long i = r ; i >= max(r - K + 1,1) ; i--)
      |                                        ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from books.cpp:3:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
books.cpp:53:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   53 |             for(long long i = r ; i >= max(r - K + 1,1) ; i--)
      |                                        ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from books.cpp:3:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
books.cpp:53:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   53 |             for(long long i = r ; i >= max(r - K + 1,1) ; i--)
      |                                        ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from books.cpp:3:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
books.cpp:53:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   53 |             for(long long i = r ; i >= max(r - K + 1,1) ; i--)
      |                                        ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from books.cpp:3:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
books.cpp:53:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   53 |             for(long long i = r ; i >= max(r - K + 1,1) ; i--)
      |                                        ~~~^~~~~~~~~~~~~