답안 #50931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50931 2018-06-15T05:53:56 Z win11905 쌀 창고 (IOI11_ricehub) C++11
0 / 100
8 ms 592 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define long long long
using namespace std;

const int N = 1e5+5;

long pref[N], A[N];

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