Submission #1210910

#TimeUsernameProblemLanguageResultExecution timeMemory
1210910ofozRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int besthub(int n, int m, int a[], long long b) { vector<long long> prfx(n); prfx[0] = a[0]; for (long long i = 1; i < n; ++i) { prfx[i] = prfx[i - 1] + a[i]; } auto getPrfx = [&](long long l, long long r) -> long long { if (l > r) return 0; long long left = (l == 0) ? 0 : prfx[l - 1]; long long right = prfx[r]; return right - left; }; int res = 1; long long l = 0, r = 0; while (r < n) { long long mid = (l + r) / 2; long long s = getPrfx(l, r) - a[mid]; long long s1 = getPrfx(l, mid - 1); long long s2 = getPrfx(mid + 1, r); long long d1 = mid - l; long long d2 = r - mid; long long score = s2 - 1LL * d2 * a[mid] + (1LL * d1 * a[mid] - s1); if (score <= b) { res = max(res, r - l + 1); ++r; } else { ++l; } } return res; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:29:22: error: no matching function for call to 'max(int&, long long int)'
   29 |             res = max(res, r - l + 1);
      |                   ~~~^~~~~~~~~~~~~~~~
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 ricehub.cpp:1:
/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:
ricehub.cpp:29:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |             res = max(res, r - l + 1);
      |                   ~~~^~~~~~~~~~~~~~~~
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 ricehub.cpp:1:
/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:
ricehub.cpp:29:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |             res = max(res, r - l + 1);
      |                   ~~~^~~~~~~~~~~~~~~~
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 ricehub.cpp:1:
/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:
ricehub.cpp:29:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |             res = max(res, r - l + 1);
      |                   ~~~^~~~~~~~~~~~~~~~
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 ricehub.cpp:1:
/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:
ricehub.cpp:29:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |             res = max(res, r - l + 1);
      |                   ~~~^~~~~~~~~~~~~~~~