답안 #895791

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895791 2023-12-30T20:48:40 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

//#define int long long

#define ll long long

bool check(int mid, vector<ll>& psum, vector<int>& x, int money){
	for(int i = mid; i < psum.size(); i++){
		ll val = x[i - mid/2];
		val *= (mid - mid/2);
		ll tot = val - (psum[i - mid/2] - psum[i - mid]);
		tot += (psum[i] - psum[i - mid/2]) - (x[i-mid/2] * (mid/2));
		if(tot <= money){
			return true;
		}
	}
	return false;
}

int besthub(int r, int l, vector<int> x, int b){
	vector<ll> psum(r+1);
	psum[0] = 0;
	for(int i = 1; i <= r; i++){
		psum[i] = psum[i-1] + x[i-1];
	}
	int left = 0, right = r, mid;
	while(left < right){
		mid = (left + right + 1)/2;
		if(check(mid, psum, x, b)){
			left = mid;
		}else{
			right = mid-1;
		}
	}
	return left;
}

// signed main(){
// 	ios_base::sync_with_stdio(0); cin.tie(0);
// 	vector<int> v;
// 	v.push_back(1); v.push_back(2); v.push_back(10); v.push_back(12); v.push_back(14);
// 	cout << besthub(5, 20, v, 6);
// }

Compilation message

ricehub.cpp: In function 'bool check(int, std::vector<long long int>&, std::vector<int>&, int)':
ricehub.cpp:10:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for(int i = mid; i < psum.size(); i++){
      |                   ~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccbOgZKT.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status