답안 #29495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29495 2017-07-19T13:52:34 Z inqr 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
using namespace std;
vector < int > presum;
int fienum;
long long b,ans;
long long sum(int l,int r){
	if(l==0)return presum[r];
	else return presum[r]-presum[l-1];
}
long long comp(int l,int r,int X[]){
	long long m=(l+r)/2;
	long long lc=m-l,rc=r-m;
	return lc*X[m]-sum(l,m-1)+sum(m+1,r)-rc*X[m];
}
void solve(int s,int X[]){
	int l=s,r=fienum-1;
	while(l<=r){
		int m=(l+r)/2;
		//printf("s=%d l=%d r=%d m=%d comp=%d %d\n",s,l,r,m,comp(s,m,X).st,comp(s,m,X).nd);
		if(comp(s,m,X)<=b){
			l=m+1;
			ans=max(ans,m-s+1);
		}
		else r=m-1;
	}
}
int besthub(int R, int L, int X[], long long B)
{
	fienum=R;b=B;
	presum.resize(R);
	presum[0]=X[0];
	for(int i=1;i<R;i++)presum[i]=presum[i-1]+X[i];
	for(int i=0;i<R;i++){
		solve(i,X);
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'void solve(int, int*)':
ricehub.cpp:28:21: error: no matching function for call to 'max(long long int&, int)'
    ans=max(ans,m-s+1);
                     ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from ricehub.cpp:2:
/usr/include/c++/5/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++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
ricehub.cpp:28:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    ans=max(ans,m-s+1);
                     ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from ricehub.cpp:2:
/usr/include/c++/5/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++/5/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
ricehub.cpp:28:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    ans=max(ans,m-s+1);
                     ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from ricehub.cpp:2:
/usr/include/c++/5/bits/stl_algo.h:3457:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^
/usr/include/c++/5/bits/stl_algo.h:3457:5: note:   template argument deduction/substitution failed:
ricehub.cpp:28:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    ans=max(ans,m-s+1);
                     ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from ricehub.cpp:2:
/usr/include/c++/5/bits/stl_algo.h:3463: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++/5/bits/stl_algo.h:3463:5: note:   template argument deduction/substitution failed:
ricehub.cpp:28:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    ans=max(ans,m-s+1);
                     ^