Submission #741140

# Submission time Handle Problem Language Result Execution time Memory
741140 2023-05-13T15:51:56 Z LCJLY Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

int besthub(int R, int L, int X[], long long B)
{
	int n=R,k=L;
	long long arr[n+5];
	for(int x=0;x<n;x++){
		arr[x+1]=X[x];
	}	
	
	long long psum[n+5];
	for(int x=1;x<=n;x++){
		psum[x]=psum[x-1]+arr[x];
	}
	
	int l=1;
	int ans=0;
	
	for(long long x=1;x<=n;x++){
		while(l<x){
			int mid=(l+x)/2;
			long long cost=arr[mid]*(mid-l)-(psum[mid-1]-psum[l-1])+(psum[x]-psum[mid])-arr[mid]*(x-mid);
			
			if(cost>B){
				l++;
			}
			else{
				break;
			}
		}
		ans=max(ans,x-l+1);
	}
	
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:34:20: error: no matching function for call to 'max(int&, long long int)'
   34 |   ans=max(ans,x-l+1);
      |                    ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from ricehub.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
ricehub.cpp:34:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   34 |   ans=max(ans,x-l+1);
      |                    ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from ricehub.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
ricehub.cpp:34:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   34 |   ans=max(ans,x-l+1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
ricehub.cpp:34:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |   ans=max(ans,x-l+1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
ricehub.cpp:34:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |   ans=max(ans,x-l+1);
      |                    ^
ricehub.cpp:8:10: warning: unused variable 'k' [-Wunused-variable]
    8 |  int n=R,k=L;
      |          ^