Submission #1140747

#TimeUsernameProblemLanguageResultExecution timeMemory
1140747SangRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "ricehub.h" using namespace std; #define int long long #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--) #define fi first #define se second #define pb push_back #define ALL(a) (a).begin(), (a).end() #define task "kbsiudthw" typedef vector<int> vi; typedef pair<int, int> ii; typedef pair<int, ii> pii; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 2277; int R, L, B, pref[N], a[N]; int get(int l, int r){ int m = (l + r)/2; return (m - l + 1) * a[m] - (pref[m] - pref[l-1]) + pref[r] - pref[m] - (r - m) * a[m]; } int32_t besthub(int32_t R, int32_t L, int32_t X[], long long B) { FOR (i, 1, R) a[i] = X[i-1], pref[i] = pref[i-1] + a[i]; int32_t ans = 0; int j = 1; FOR (i, 1, R){ while (get(j, i) > B) ++j; ans = max(ans, i - j + 1); } return ans; } //signed main(){ // ios_base::sync_with_stdio(0); // cin.tie(0); cout.tie(0); // if (fopen(task".inp", "r")){ // freopen(task".inp", "r", stdin); // freopen(task".out", "w", stdout); // } // cin >> R >> L >> B; // FOR (i, 1, R) cin >> a[i], pref[i] = pref[i-1] + a[i]; // int ans = 0; // int j = 1; // FOR (i, 1, R){ // while (get(j, i) > B) ++j; // ans = max(ans, i - j + 1); // } // cout << ans; // // return 0; //}

Compilation message (stderr)

ricehub.cpp: In function 'int32_t besthub(int32_t, int32_t, int32_t*, long long int)':
ricehub.cpp:36:18: error: no matching function for call to 'max(int32_t&, long long int)'
   36 |         ans = max(ans, i - j + 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:36:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   36 |         ans = max(ans, i - j + 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:36:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   36 |         ans = max(ans, i - j + 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:36:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   36 |         ans = max(ans, i - j + 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:36:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   36 |         ans = max(ans, i - j + 1);
      |               ~~~^~~~~~~~~~~~~~~~