제출 #577393

#제출 시각아이디문제언어결과실행 시간메모리
577393Theo830커다란 상품 (IOI17_prize)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define ull unsigned int #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "prize.h" ll maxi = 0; ll solve(ll l,ll r,ll L,ll R){ if(l > r){ return -1; } ll mid = (l+r)/2; vector<int>res = ask(mid); if(res[0] == 0 && res[1] == 0){ return mid; } if(l == r){ return -1; } ll ans; ll pos = mid; while(pos < r && (res[0] + res[1]) < maxi){ pos++; res = ask(pos); } if(res[0] + res[1] < maxi){ pos = mid - 1; while(pos > l && (res[0] + res[1]) < maxi){ pos--; res = ask(pos); } } if(res[0] + res[1] == maxi){ if(res[0] - L > res[1] - R){ ans = solve(l,mid,L,R + res[1]); if(ans == -1){ ans = solve(mid+1,r,L + res[0],R); } } else{ ans = solve(mid+1,r,L + res[0],R); if(ans == -1){ ans = solve(l,mid,L,R + res[1]); } } } return ans; } int find_best(int n){ srand(time(0)); ll k = 20; while(k--){ vector<int> res = ask(rand() % n); maxi = max(maxi,res[0] + res[1]); } return solve(0,n-1,0,0); }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:74:40: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   74 |         maxi = max(maxi,res[0] + res[1]);
      |                                        ^
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 prize.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:
prize.cpp:74:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   74 |         maxi = max(maxi,res[0] + res[1]);
      |                                        ^
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 prize.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:
prize.cpp:74:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   74 |         maxi = max(maxi,res[0] + res[1]);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prize.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:
prize.cpp:74:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   74 |         maxi = max(maxi,res[0] + res[1]);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prize.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:
prize.cpp:74:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   74 |         maxi = max(maxi,res[0] + res[1]);
      |                                        ^