답안 #741141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741141 2023-05-13T15:52:47 Z LCJLY 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
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];
	}
	
	long long l=1;
	int ans=0;
	
	for(long long x=1;x<=n;x++){
		while(l<x){
			long long 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,(int)x-l+1);
	}
	
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:34:25: error: no matching function for call to 'max(int&, long long int)'
   34 |   ans=max(ans,(int)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:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   34 |   ans=max(ans,(int)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:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   34 |   ans=max(ans,(int)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:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |   ans=max(ans,(int)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:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |   ans=max(ans,(int)x-l+1);
      |                         ^
ricehub.cpp:8:10: warning: unused variable 'k' [-Wunused-variable]
    8 |  int n=R,k=L;
      |          ^