제출 #895832

#제출 시각아이디문제언어결과실행 시간메모리
895832vjudge1Rice Hub (IOI11_ricehub)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; typedef long long ll; ll r, l, x, b; vector<ll> pref; int check(int R, int L, int *fields, ll B) { ll lo = L, hi = R; while (lo < hi){ ll mid = (lo + hi + 1)/2; ll k = (L + mid)/2; ll cost = fields[k - 1]*(k - L + 1) - (pref[k] - pref[L - 1]) +(pref[mid] - pref[k]) - (mid - k)*fields[k-1]; if (cost > B) { hi = mid - 1; } else { lo = mid; } } return lo - L + 1; } int besthub(int R, int L, int fields[], ll B) { pref.resize(R + 1); for(int i = 0; i < R; i++){ pref[i+1] += pref[i]; pref[i+1] += fields[i]; } ll ans = INT_MIN; for (int i = 1; i <= R; i++) { ans = max(ans, check(R, i, fields, B)); } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:36:42: error: no matching function for call to 'max(ll&, int)'
   36 |     ans = max(ans, check(R, i, fields, B));
      |                                          ^
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 ricehub.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:
ricehub.cpp:36:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |     ans = max(ans, check(R, i, fields, B));
      |                                          ^
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 ricehub.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:
ricehub.cpp:36:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |     ans = max(ans, check(R, i, fields, B));
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.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:
ricehub.cpp:36:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |     ans = max(ans, check(R, i, fields, B));
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.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:
ricehub.cpp:36:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |     ans = max(ans, check(R, i, fields, B));
      |                                          ^