Submission #110415

# Submission time Handle Problem Language Result Execution time Memory
110415 2019-05-10T19:38:23 Z ioilolcom Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define endl "\n"
#define x first
#define y second
#define pii pair<int,int>
typedef long long int ll;




vector<int> v;
int besthub(int R, int L, int X[], long long B)
{
	int n=R;
	ll w=B;
	v.resize(n+1);
	for(int i=0; i<n; i++) {
		v[i+1]=X[i];
	}
	ll mx=0;
	for(int idx=1; idx<=n; idx++) {
		vector<pii> l,r;
		ll cur=0;
		ll curv=0;
		for(int i=idx+1; i<=n; i++) {
			curv+=v[i]-v[idx];
			cur++;
			r.push_back({curv,cur});
		}
		r.push_back({0,0});
		l.push_back({0,0});
		cur=0;
		curv=0;
		for(int i=idx-1; i>=0; i--) {
			curv+=abs(v[i]-v[idx]);
			cur++;
			l.push_back({curv,cur});
		}
		ll ans=0;
		for(pii u:l) {
			for(pii v:r) {
				if(u.x+v.x<=w) {
					ans=max(ans,u.y+v.y);
				}
			}
		}
		ans++;
		mx=max(mx,ans);
	}
	return mx;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:45:25: error: no matching function for call to 'max(ll&, int)'
      ans=max(ans,u.y+v.y);
                         ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
      ans=max(ans,u.y+v.y);
                         ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
      ans=max(ans,u.y+v.y);
                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
      ans=max(ans,u.y+v.y);
                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
      ans=max(ans,u.y+v.y);
                         ^