Submission #600232

# Submission time Handle Problem Language Result Execution time Memory
600232 2022-07-20T14:39:25 Z _Avocado_ Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
//#define int int64_t
using namespace std;

int bsearch(int n, int len, vector<int>&fred, vector<long long>&prefix, int budget){
	int l = -1;
	int r = n+1;
	
	while(r-l > 1){
		int m = (r+l)/2;
		int ans = 1e9;
		int mid = m/2+1;
		for(int i = m; i<=n; ++i){
			int hub = fred[mid];
			long long one = ((m/2) * hub)-(prefix[mid-1]-prefix[i-m]);
			long long two = (prefix[i]-prefix[mid-(1-m%2)]) - ((m/2)*hub);
			++mid;
			ans = min(ans, one+two);
		}
		if(ans <= budget) l = m;
		else r = m;

	}
	return l;
}
			

int besthub(int R, int L, int X[], long long B){
	int n = R;
	int len = L;
	int budget = B;
	vector<long long>prefix(n+1);
	for(int i = 1; i<=n; ++i){
		prefix[i] = prefix[i-1] + X[i-1];
	}
	
	vector<int>fred;
	fred.push_back(0);
	for(int i = 0; i<n; ++i) fred.push_back(X[i]);
	
	return bsearch(n, len, fred, prefix, budget);
}

Compilation message

ricehub.cpp: In function 'int bsearch(int, int, std::vector<int>&, std::vector<long long int>&, int)':
ricehub.cpp:19:26: error: no matching function for call to 'min(int&, long long int)'
   19 |    ans = min(ans, one+two);
      |                          ^
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:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
ricehub.cpp:19:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   19 |    ans = min(ans, one+two);
      |                          ^
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:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
ricehub.cpp:19:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   19 |    ans = min(ans, one+two);
      |                          ^
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:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
ricehub.cpp:19:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |    ans = min(ans, one+two);
      |                          ^
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:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
ricehub.cpp:19:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |    ans = min(ans, one+two);
      |                          ^