Submission #895793

# Submission time Handle Problem Language Result Execution time Memory
895793 2023-12-30T20:49:43 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
Compilation error
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 < (int)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

/usr/bin/ld: /tmp/ccf8OvgS.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