Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:8:11: error: reference to 'max' is ambiguous
    8 | cin>>a[1];max=a[1];
      |           ^~~
In file included from /usr/include/c++/12/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:65,
                 from /in/foo.cc:1:
/usr/include/c++/12/bits/stl_algo.h:5756:5: note: candidates are: 'template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)'
 5756 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/12/bits/stl_algo.h:5746:5: note:                 'template<class _Tp> _Tp std::max(initializer_list<_Tp>)'
 5746 |     max(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/12/string:50,
                 from /usr/include/c++/12/bits/locale_classes.h:40,
                 from /usr/include/c++/12/bits/ios_base.h:41,
                 from /usr/include/c++/12/ios:42,
                 from /usr/include/c++/12/istream:38,
                 from /usr/include/c++/12/sstream:38,
                 from /usr/include/c++/12/complex:45,
                 from /usr/include/c++/12/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:54:
/usr/include/c++/12/bits/stl_algobase.h:300:5: note:                 'template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/12/bits/stl_algobase.h:254:5: note:                 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/in/foo.cc:4:5: note:                 'int max'
    4 | int max;
      |     ^~~
/in/foo.cc:13:26: error: reference to 'max' is ambiguous
   13 |                 if(a[i]>=max)cnt++;
      |                          ^~~
/usr/include/c++/12/bits/stl_algo.h:5756:5: note: candidates are: 'template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)'
 5756 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/12/bits/stl_algo.h:5746:5: note:                 'template<class _Tp> _Tp std::max(initializer_list<_Tp>)'
 5746 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/12/bits/stl_algobase.h:300:5: note:                 'template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/12/bits/stl_algobase.h:254:5: note:                 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/in/foo.cc:4:5: note:                 'int max'
    4 | int max;
      |     ^~~

信息

递交者
类型
自测
题目
P2548 美丽的黄山
语言
C++
递交时间
2025-10-29 12:00:05
评测时间
2025-10-29 12:00:05
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes