답안 #157599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157599 2019-10-12T14:40:27 Z RoundMango 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
long long a[10000005], sum[10000005], n, l = 1, r, md, mx, xx, ans;
//int besthub(int R, int L, int a[], long long b) {
int main() {
	int R, L, b;
	cin>>R>>L>>b;
	for (int i = 0; i < R; i++)
		cin>>a[i];
	for (int i = 1; i <= R; i++) 
		sum[i] = sum[i-1] + a[i-1];
	r = R;
	while (l < r) {
		ans = b+1;
		md = (l+r+1)>>1;
		for (int i = md; i <= R; i++) {
			n = i-md+1;
			mx = (i+n+1)>>1;
			xx = sum[i] - sum[mx] - (i-mx)*a[mx-1] + a[mx-1]*(mx-n) - sum[mx-1] + sum[n-1];
			ans = min(ans, xx);
		}
	    if (ans <= b) l = md;
		else r = md-1;
	}
	cout<<l;
}

Compilation message

/tmp/cc4EmIA2.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccKw6Xx4.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/cc4EmIA2.o: In function `main':
grader.cpp:(.text.startup+0x92): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status