AtcoderBeginnerContestのC問題(https://atcoder.jp/contests/abc189/tasks/abc189_c)を解いていてmin_elementを使いたいと思いコードを書いたのですが、良く分からないエラーが出ました。多分原因はmin_elementだと思いますが、どう直したら良いのか分からないのでご教授願います。
C++
1#include <bits/stdc++.h> 2using namespace std; 3#define ll long long 4#define ld long double 5#define rep(i,a,n) for (ll i = a;i<(n);++i) 6#define all(v) v.begin(),v.end() 7#define bit(n) (1LL<<(n)) 8template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } 9template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } 10class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n; 11public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}}; 12/*------------------------------------------------------------------------------------------------------------------------------------------------*/ 13int main() { 14 ll n; 15 cin>>n; 16 vector<ll>a(n); 17 rep(i,0,n)cin>>a.at(i); 18 ll ans=0; 19 rep(i,0,n){ 20 rep(j,i,n){ 21 ll min=min_element(a.at(i),a.at(j)); 22 ans=max(ans,min*(j-i+1)); 23 } 24 } 25 cout<<ans; 26 return 0; 27}
エラー内容
error
1In file included from /usr/include/c++/6/bits/stl_algobase.h:71:0, 2 from /usr/include/c++/6/bits/char_traits.h:39, 3 from /usr/include/c++/6/ios:40, 4 from /usr/include/c++/6/istream:38, 5 from /usr/include/c++/6/sstream:38, 6 from /usr/include/c++/6/complex:45, 7 from /usr/include/c++/6/ccomplex:39, 8 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:52, 9 from prog.cpp:1: 10/usr/include/c++/6/bits/predefined_ops.h: In instantiation of ‘constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = long long int; _Iterator2 = long long int]’: 11/usr/include/c++/6/bits/stl_algo.h:5460:12: required from ‘constexpr _ForwardIterator std::__min_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’ 12/usr/include/c++/6/bits/stl_algo.h:5484:43: required from ‘constexpr _FIter std::min_element(_FIter, _FIter) [with _FIter = long long int]’ 13prog.cpp:21:47: required from here 14/usr/include/c++/6/bits/predefined_ops.h:43:16: error: invalid type argument of unary ‘*’ (have ‘long long int’) 15 { return *__it1 < *__it2; } 16 ^~~~~~ 17/usr/include/c++/6/bits/predefined_ops.h:43:25: error: invalid type argument of unary ‘*’ (have ‘long long int’) 18 { return *__it1 < *__it2; } 19 ^~~~~~ 20
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。