10
24
2015
0

hiho一下 第六十九周

#include <cstdio>

using namespace std;
int N, K, V[100005];
inline bool Ckd(long long T)
{
	int Sc = 0;
	long long C = T;
	for (int i = 1; i <= N; i ++, C += T)
	{
		if (C <= V[i]) C = 0;
		else ++ Sc, C = C - V[i];
	}
	return Sc + Sc > N;
}
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; i ++) scanf("%d", V + i);
	int L = 1, R = K + 1, M;
	while (L < R - 1)
	{
		M = (L + R) >> 1;
		Ckd(M) ? R = M : L = M;
	}
	printf("%d\n", R);
	return 0;
}
Category: hihocoder | Tags: 二分搜索

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com