Submission #80194

# Submission time Handle Problem Language Result Execution time Memory
80194 2018-10-19T13:49:06 Z farukkastamonuda Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
using namespace std;
lo int n,T[10],mx,b,ans;
lo int A[li],pre[li];
bool chechk(lo int l,lo int r){
	int mid=(l+r)/2;
	lo int sum=1ll*A[mid]*(mid-l+1)-(pre[mid]-pre[l-1]);
	sum+=(pre[r]-pre[mid-1])-1ll*A[mid]*(r-mid+1);
	return sum<=b;
}
int besthub(int R,int L,int X[],lo int B){
	n=R;
	for(int i=1;i<=n;i++) A[i]=X[i-1];
	mx=L;
	b=B;
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+A[i];
	for(int i=1;i<=n;i++){
		int l=i,r=n;
		while(l<=r){
			int mid=(l+r)/2;
			if(chechk(i,mid)) l=mid+1;
			else r=mid-1;
		}
		ans=max(ans,l-i);
	}
	return ans;
}
//~ int main(){
	//~ T[0]=1,T[1]=2,T[3]=10,T[4]=12,T[5]=14;
	//~ int ty=besthub(5,20,T,6);
	//~ printf("%d\n",ty);
	//~ return 0;

//}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:33:18: error: no matching function for call to 'max(long long int&, int)'
   ans=max(ans,l-i);
                  ^
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:2:
/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:33:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   ans=max(ans,l-i);
                  ^
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:2:
/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:33:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   ans=max(ans,l-i);
                  ^
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:2:
/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:33:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   ans=max(ans,l-i);
                  ^
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:2:
/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:33:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   ans=max(ans,l-i);
                  ^