제출 #1158506

#제출 시각아이디문제언어결과실행 시간메모리
1158506zhasynHorses (IOI15_horses)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> // #include "horses.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define pf push_front using namespace std; using namespace __gnu_pbds; #define F first #define S second typedef long long ll; #define pii pair <int, int> #define pll pair <ll, ll> typedef long double ld; const ll N = 5 * 1e5 + 100, M = 2 * 1e6 + 100, len = 21, inf = 1e18; const ll mod = 1e9 + 7; ll um(ll a, ll b){ return (1LL * a * b) % mod; } ll subr(ll a, ll b){ return ((1LL * a - b) % mod + mod) % mod; } typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>o_set; int x[N], p[N], n; ll calc(){ int j = n - 1; ll mx = p[n - 1] * x[n - 1]; for(int i = n - 2; i >= 0; i--){ if(mx > 1e9) break; if(p[i] > mx) j = i; mx = max(mx, p[i]) * x[i]; } ll xx = 1; for(int i = 0; i <= j; i++){ xx = um(xx, x[i]); } return um(xx, p[j]); } int init(int nx, int xx[], int pp[]) { n = nx; for(int i = 0; i < n; i++){ x[i] = xx[i]; p[i] = pp[i]; } return calc(); } int updateX(int pos, int val) { x[pos] = val; return calc(); } int updateY(int pos, int val) { p[pos] = val; return calc(); } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); return 0; }

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

horses.cpp: In function 'll calc()':
horses.cpp:31:17: error: no matching function for call to 'max(ll&, int&)'
   31 |         mx = max(mx, p[i]) * x[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 horses.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:
horses.cpp:31:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |         mx = max(mx, p[i]) * x[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 horses.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:
horses.cpp:31:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |         mx = max(mx, p[i]) * x[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 horses.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:
horses.cpp:31:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |         mx = max(mx, p[i]) * x[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 horses.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:
horses.cpp:31:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |         mx = max(mx, p[i]) * x[i];
      |              ~~~^~~~~~~~~~