답안 #58335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58335 2018-07-17T13:49:24 Z PeppaPig 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 5e3 + 5;

long long sum[N];

int besthub(int R, int L, int X[], long long B)
{
	for(int i = 1; i <= R; i++) sum[i] = sum[i - 1] + X[i - 1];
	int res = 0;
	int l = 0, r = R;
	while(l <= r) {
		int mid = (l + r) >> 1;
		int m = mid >> 1;
		long long ret = LLONG_MAX;
		for(int i = 1; i <= R - mid + 1; i++) {
			if(mid == 1) ret = min(ret, 0);
			if(mid == 2) ret = min(ret, 1LL * (X[i + 1] - X[i]));
			else {
				long long t = sum[i + mid - 1] - sum[i + m] - sum[i + m - 1] + sum[i - 1];
				if(mid & 1) ret = min(ret, t);
				else ret = min(ret, t + X[i + m - 1]);
			}
		}
		if(ret <= B) res = mid, l = mid + 1;
		else r = mid - 1;
	}

	return res;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:20:33: error: no matching function for call to 'min(long long int&, int)'
    if(mid == 1) ret = min(ret, 0);
                                 ^
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:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
ricehub.cpp:20:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    if(mid == 1) ret = min(ret, 0);
                                 ^
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:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
ricehub.cpp:20:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    if(mid == 1) ret = min(ret, 0);
                                 ^
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:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
ricehub.cpp:20:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    if(mid == 1) ret = min(ret, 0);
                                 ^
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:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
ricehub.cpp:20:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    if(mid == 1) ret = min(ret, 0);
                                 ^