/ Vijos /

记录详情

Compile Error

foo.cc: In function 'int main()':
foo.cc:22:38: error: no matching function for call to 'max(long long int&, int&)'
   22 |         for(int i=1;i<=k;++i) ans=max(ans,f[i]);
      |                                   ~~~^~~~~~~~~~
In file included from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/bits/char_traits.h:39,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/ios:40,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/istream:38,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/sstream:38,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/complex:45,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/ccomplex:39,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h:54,
                 from foo.cc:1:
/nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.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/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
foo.cc:22:38: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 |         for(int i=1;i<=k;++i) ans=max(ans,f[i]);
      |                                   ~~~^~~~~~~~~~
In file included from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/bits/char_traits.h:39,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/ios:40,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/istream:38,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/sstream:38,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/complex:45,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/ccomplex:39,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h:54,
                 from foo.cc:1:
/nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.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/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
foo.cc:22:38: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 |         for(int i=1;i<=k;++i) ans=max(ans,f[i]);
      |                                   ~~~^~~~~~~~~~
In file included from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/algorithm:62,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h:65,
                 from foo.cc:1:
/nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
foo.cc:22:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 |         for(int i=1;i<=k;++i) ans=max(ans,f[i]);
      |                                   ~~~^~~~~~~~~~
In file included from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/algorithm:62,
                 from /nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h:65,
                 from foo.cc:1:
/nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/nix/store/wy4ywjsch9q2hj5lphqjdg9p2kf7w0ls-gcc-11.3.0/include/c++/11.3.0/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
foo.cc:22:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 |         for(int i=1;i<=k;++i) ans=max(ans,f[i]);
      |                                   ~~~^~~~~~~~~~
foo.cc:23:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   23 |         printf("%d\n",ans);
      |                 ~^    ~~~
      |                  |    |
      |                  int  long long int
      |                 %lld
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1623 开心农场(HOI)
语言
C++
递交时间
2023-07-17 11:44:48
评测时间
2023-07-17 11:44:48
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes