답안 #977749

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977749 2024-05-08T10:30:54 Z Amaarsaa 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
//#include "ricehub.h"
using namespace std;
using ll = long long;
ll Pre[100005];
ll Sum(ll l, ll r) {
	if ( l == 0) return Pre[r];
	return Pre[r] - Pre[l - 1];
}
int besthub(int R, int L, int X[], long long B)	{
	ll s;
	int i, ans = 1, mn, l, r,lo, hi, mid;
	for (i = 0; i < R; i ++) {
		if ( i == 0) Pre[i] = X[i];
		else Pre[i] = Pre[i - 1] + X[i];
	}
	for (int i = 0; i + 1 < R; i ++) {
		if ( X[i + 1] - X[i] > B) continue;
		lo = 1;
		hi = min(i + 1, R - (i + 1)) + 1 ;
		while ( lo  < hi ) {
			mid = (lo +hi)/2;
			l = i - mid;
			r = i + mid;
		//	cout << mid << " " <<l << " " << i << " " << i  + 1 << " " << r<<" " <<Sum(i + 1, r)  << " " << Sum(l, i) << endl;
			if ( Sum(i + 1, r) - Sum(l, i - 1) <= B) lo = mid + 1;
			else hi = mid;
		}
		mid = lo  ;
	//	cout << mid << endl;
		
		l = i - mid ;
		r = i + mid;
		s =  Sum(i + 1, r - 1) - Sum(l + 1, i - 1) ;
	//	cout << l << " " << r <<" " << s << endl;
		mn = INT_MAX;
		if ( l >= 0) {
			mn = min(mn, X[i] - X[l]);
		}
		if ( r < R) {
			mn = min(mn, X[r] - X[i]);
		}
		if (mn + s <= B) {
			ans = max(ans, r - l);
		}
		else ans = max(ans, r - l - 1);
	}
	

	return ans;
}

int R, L, X[100005], B;
void inp() {
	cin >> R >> L >> B;
	for (int i = 0; i < R; i ++) cin >> X[i];
}

int main() {
	inp();
	cout << besthub(R, L, X, B) << endl;
}

Compilation message

/usr/bin/ld: /tmp/cc2L3vSe.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccVpJJTf.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status