Submission #478834

# Submission time Handle Problem Language Result Execution time Memory
478834 2021-10-08T15:02:47 Z nicetrymaza Rice Hub (IOI11_ricehub) C++14
Compilation error
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;

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] - a[i - mi];
				ll c2 = a[i + 2] - a[i + 2 + mj];
				if(mi != 0) c1 += (X[i] - X[i - 1]) * mi;
				c2 += (X[i + 1] - X[i]) * mj;
				ll c3 = c1 + c2;
				if(c3 <= B) {
					ans = m;
					l = m + 1;
					i = R;
					yes = false;
				}
			}
		}
		if(yes) r = m - 1;
	}
	return ans;
}

Compilation message

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