답안 #235857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
235857 2020-05-30T07:59:42 Z Dilshod_Imomov 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include "ricehub.h"	
#include <bits/stdc++.h>
using namespace std;
# define LL long long

long long ps[100100];

LL besthub(int n, int mx, int a[], long long b)
{
	for ( LL i = 0; i < n; i++ ) {
		ps[i] = a[i];
		if ( i ) {
			ps[i] += ps[i - 1];
		}
	}
	LL ans = 1;
	for ( LL i = 0; i < n; i++ ) {
		LL x = a[i];
		// cout << x << '\n';
		// for ( auto j: vc ) {
		// 	cout << j << ' ';
		// }
		// cout << "\n";
		LL l = i + 1, r = n - 1, mid;
		while ( l <= r ) {
			mid = (l + r) / 2;
			long long sum = ps[mid] - ps[i];
			sum -= (mid - i) * x;
			long long left = b - sum;
			if ( left < 0 ) {
				r = mid - 1;
			}
			else {
				// cout << mid << '\n';
				ans = max( ans, mid - i + 1 );
				LL ll = 0, rr = i - 1, mid1, ind = i;
				while ( ll <= rr ) {
					mid1 = (ll + rr) / 2;
					long long sum1 = ps[i - 1];
					if ( mid1 ) {
						sum1 -= ps[mid1 - 1];
					}
					sum1 = (i - mid1) * x - sum1;
					if ( sum1 > left ) {
						ll = mid1 + 1;
					}
					else {
						rr = mid1 - 1;
						ind = mid1;
						// ans = max( ans, (mid - i) + (i - ind) + 1 );
					}
				}
				/*
				auto it = upper_bound( vc.begin(), vc.end(), left );
				// it--;
				if ( it != vc.begin() ) {
					it--;
				}
				LL ind = it - vc.begin();*/
				// cout << a[j] << ' ' << pr << ' ' << ind << '\n';
				ans = max( ans, (mid - i) + (i - ind) + 1 );
				l = mid + 1;
			}
		}
		/*
		long long pr = 0;
		for ( LL j = i + 1; j < n; j++ ) {
			pr += a[j] - x;
			LL left = b - pr;
			// cout << a[j] << ' ' << left << '\n';
			if ( left < 0 ) {
				continue;
			}
			ans = max( ans, j - i + 1 );
			auto it = upper_bound( vc.begin(), vc.end(), left );
			// it--;
			if ( it != vc.begin() ) {
				it--;
			}
			LL ind = it - vc.begin();
			// cout << a[j] << ' ' << pr << ' ' << ind << '\n';
			ans = max( ans, j - i + ind + 1 );
		}*/
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'long long int besthub(int, int, int*, long long int)':
ricehub.cpp:8:4: error: ambiguating new declaration of 'long long int besthub(int, int, int*, long long int)'
 LL besthub(int n, int mx, int a[], long long b)
    ^~~~~~~
In file included from ricehub.cpp:1:0:
ricehub.h:1:5: note: old declaration 'int besthub(int, int, int*, long long int)'
 int besthub(int R, int L, int X[], long long B);
     ^~~~~~~