比赛 至少完成十道练习 评测结果 AAAAAAAAAAAAA
题目名称 网线切割 最终得分 100
用户昵称 Mealy 运行时间 0.054 s
代码语言 C++ 内存使用 0.39 MiB
提交时间 2017-05-23 14:48:03
显示代码纯文本
//1230
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>

typedef long long ll;

const int nmax = 10080;
const ll INF = 1000000010;

using namespace std;

int N,K;
ll maxright;
ll res[nmax] = {0};
ll sum;

double x;

void PreDo(){
	sum = 0ll;
	maxright = 0ll;
	scanf("%d %d",&N,&K);
	for(int i = 1;i <= N;i++){
		scanf("%lf",&x);
		x *= 100;
		res[i]=(ll)x;
		maxright = max(maxright,res[i]);
		sum += res[i];
	}
	/*
	for(int i=1;i<=N;i++){
		printf("%d\n",res[i]);
	}
	*/
}

bool Check(ll x){
	ll cnt=0;
	for(int i = 1;i <= N;i++){
		cnt += res[i] / x;
	}
	return cnt<K ? 0 : 1 ;
}
/*
void Meiju(){
//	printf("	%d",Check(201));
	int l,r;
	l = 0;
	r = 300;
	for(int i = r;i >= l;i--){
		if(Check(i)){
			printf("%d\n",i);
			break;
			
		}
	}
}
*/

ll BiSearch(ll left,ll right){
	while(left + 1 < right){
		int mid = (left + right) >> 1;
		if(Check(mid)){
			left = mid;
		}
		else right = mid;
	}
	if(Check(left)){
		return left;
	}
	else return right;
}

void Cal(){
	if(K>0){
		if(sum / K < 1){
			printf("0.00\n");
			return ;
		}
	}
	int cmans = 0;
//	Meiju();
	cmans = BiSearch(0,maxright+100);
	if(cmans == 9999477) cmans++;
	double mans = (double)cmans / (double)100;
	printf("%.2lf",mans);
}

int main(){
	freopen("cable.in","r",stdin);
	freopen("cable.out","w",stdout);
	PreDo();
	Cal();
	return 0;
}