답안 #50937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50937 2018-06-15T06:46:14 Z win11905 쌀 창고 (IOI11_ricehub) C++11
0 / 100
7 ms 596 KB
#include "ricehub.h"
#define long long long
using namespace std;

const int N = 1e5+5;

long pref[N];

int besthub(int R, int L, int X[], long B) {
	for(int i = 0; i < R; ++i) pref[i+1] = pref[i] + X[i];
	auto f = [&](int l, int r, int m) {
		long lhs = (pref[m] * (m-l)) - (pref[m-1] - pref[l-1]);
		long rhs = (pref[r] - pref[m]) - (pref[m] * (r - m));
		return lhs + rhs <= B;
	};
	int l = 1, r = R;
	while(l < r) {
		int m = (l + r + 1) >> 1;
		bool st = false;
		for(int x = 1, y = m; y <= R; x++, y++) {
			int z = (x + y) >> 1;
			st |= f(x, y, z);
			st |= f(x, y, z+1);
		}
		if(st) l = m;
		else r = m - 1;
	}
	return l;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -