답안 #478860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
478860 2021-10-08T16:03:39 Z nicetrymaza 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define add push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define filein(a) freopen(a, "r", stdin);
#define fileout(a) freopen(a, "w", stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
 
const int N = 100011;
const ll MOD = 1000000007;
 
int besthub(int R, ll L, ll X[], ll B) {
	if(R == 1) return 1;
	ll a[N], b[N];
	a[0] = 0;
	b[R + 1] = 0;
	for(int i = 1; i <= R; i++) {
		if(i == 1) a[i] = 0;
		else a[i] = a[i - 1] + (i - 1) * (X[i - 1] - X[i - 2]);
	}

	for(int i = R; i >= 1; i--) {
		if(i == R) b[i] = 0;
		else b[i] = b[i + 1] + (R - i) * (X[i] - X[i - 1]);
	}
	int l = 1, r = R, ans = 1;
	while(l <= r) {
		bool yes = true;
		int m = (l + r) / 2;
		int mi = m / 2, mj = (m + 1) / 2;
		for(int i = mi; (i + mj) < R; i++) {
			if(i == 0) {
				if(B >= (X[i + 1] - X[i])) {
					ans = 2;
					l = m + 1;
					i = R;
					yes = false;
				}
			}
			else {
				ll c1 = a[i + 1] - a[i - mi + 1] - (i - mi) * (X[i] - X[i - mi]);
				ll c2 = b[i + 1] - b[i + 1 + mj] - (R - i - 1 - mj) * (X[i + mj] - X[i]);
				if((c1 + c2) <= B) {
					ans = m + 1;
					l = m + 1;
					i = R;
					yes = false;
				}
			}
		}
		if(yes) r = m - 1;
	}
	return ans;
}

Compilation message

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