Submission #94775

# Submission time Handle Problem Language Result Execution time Memory
94775 2019-01-23T17:04:08 Z MvC Rice Hub (IOI11_ricehub) C++11
Compilation error
0 ms 0 KB
#include "ricehub.h"
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
ll n,m,l,r,mid,i;
ll b,x[nmax],s[nmax];
int ok(int k,int md)
{
    for(int i=k;i<=n;i++)
    {
        ll tot=-1LL*(1LL*s[i-md+1]-1LL*s[i-k])+1LL*(1LL*i-1LL*md+1LL*1-1LL*i+1LL*k)*1LL*x[md]+1LL*s[i]-1LL*s[i-md+1]-1LL*(1LL*i-1LL*i+1LL*md-1LL*1)*1LL*x[md];
        if(tot<=b)return 1;
    }
    return 0;
}
int besthub(int N,int m,int y[],ll B)
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	b=B;
	n=N;
	for(i=1;i<=n;i++)
	{
	    x[i]=y[i-1];
	    s[i]=s[i-1]+x[i];
	}
	l=1,r=n;
	while(l<=r)
	{
	    mid=(l+r)/2;
	    if(ok(mid,(mid/2)+1))l=mid+1;
	    else r=mid-1;
	}
	if(ok(l-1,((l-1)/2)+1))return max(l-1,1);
	else return 1;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:49:41: error: no matching function for call to 'max(ll, int)'
  if(ok(l-1,((l-1)/2)+1))return max(l-1,1);
                                         ^
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:3:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> 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:49:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  if(ok(l-1,((l-1)/2)+1))return max(l-1,1);
                                         ^
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:3:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> 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:49:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  if(ok(l-1,((l-1)/2)+1))return max(l-1,1);
                                         ^
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:3:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> _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:49:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  if(ok(l-1,((l-1)/2)+1))return max(l-1,1);
                                         ^
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:3:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> _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:49:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  if(ok(l-1,((l-1)/2)+1))return max(l-1,1);
                                         ^