답안 #335791

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335791 2020-12-14T03:00:41 Z sumit_kk10 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int main(){
	fast;
	long long int r, l;
	cin >> r >> l;
	long long int a[r], b, ans = 0;
	cin >> b;
	for(int i = 0; i < r; ++i)
		cin >> a[i];
	for(int i = 0; i < r; ++i){
		int j = i - 1, k = i + 1;
		long long int budget = b, how_many = 1;
		while(budget){
			if(j < 0 and k >= r) break;
			if(abs(a[j] - a[i]) <= abs(a[k] - a[i]) and abs(a[j] - a[i]) <= budget and j >= 0){
				// if(i == 3)
					// cout << a[j] << ' ';
				budget -= abs(a[j] - a[i]);
				++how_many;
				--j;
			}
			else if(abs(a[k] - a[i]) <= abs(a[j] - a[i]) and abs(a[k] - a[i]) <= budget and k < r){
				budget -= abs(a[k] - a[i]);
				++how_many;
				++k;
			}
			else
				break;
		}
		// cout << how_many << ' ';
		ans = max(ans, how_many);
	}
	cout << ans;
	return 0;
}

Compilation message

/tmp/ccGeS46c.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccRuyPPO.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/ccGeS46c.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