Compile Error

foo.cc: In function 'int main()':
foo.cc:15:28: error: no matching function for call to 'max(int&, long long int&)'
   15 |                 a[t[i]]=max(a[t[i]],r[i])
      |                         ~~~^~~~~~~~~~~~~~
In file included from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/string:50,
                 from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/locale_classes.h:40,
                 from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/ios_base.h:41,
                 from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/ios:42,
                 from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/istream:38,
                 from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/sstream:38,
                 from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/complex:45,
                 from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/ccomplex:39,
                 from stdc++.h:54:
/nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
foo.cc:15:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   15 |                 a[t[i]]=max(a[t[i]],r[i])
      |                         ~~~^~~~~~~~~~~~~~
/nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
foo.cc:15:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   15 |                 a[t[i]]=max(a[t[i]],r[i])
      |                         ~~~^~~~~~~~~~~~~~
In file included from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/algorithm:61,
                 from stdc++.h:65:
/nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/stl_algo.h:5746:5: note: candidate: 'template<class _Tp> _Tp std::max(initializer_list<_Tp>)'
 5746 |     max(initializer_list<_Tp> __l)
      |     ^~~
/nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/stl_algo.h:5746:5: note:   template argument deduction/substitution failed:
foo.cc:15:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |                 a[t[i]]=max(a[t[i]],r[i])
      |                         ~~~^~~~~~~~~~~~~~
/nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/stl_algo.h:5756:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)'
 5756 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/stl_algo.h:5756:5: note:   template argument deduction/substitution failed:
foo.cc:15:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |                 a[t[i]]=max(a[t[i]],r[i])
      |                         ~~~^~~~~~~~~~~~~~
foo.cc:16:21: error: 'i' was not declared in this scope
   16 |         for(int i=1;i<=n;i++)
      |                     ^
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
自测
题目
P1000 大象喝水
语言
C++
递交时间
2023-10-28 21:59:42
评测时间
2023-10-28 21:59:42
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes