結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー fiordfiord
提出日時 2015-08-06 00:31:01
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 560 bytes
コンパイル時間 1,985 ms
コンパイル使用メモリ 148,712 KB
実行使用メモリ 11,480 KB
最終ジャッジ日時 2023-09-25 04:05:37
合計ジャッジ時間 9,332 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
11,480 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 60 ms
4,376 KB
testcase_03 AC 113 ms
4,376 KB
testcase_04 AC 136 ms
4,380 KB
testcase_05 AC 137 ms
4,376 KB
testcase_06 AC 136 ms
4,376 KB
testcase_07 AC 156 ms
4,376 KB
testcase_08 AC 157 ms
4,376 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<int> l(200000);
int n;
long long int k;
bool check(double u){
	if(u==0)	return true;
	long long int cnt=0;
	for(int i=0;i<n;i++){
		cnt+=l[i]/u;
	}
	if(cnt>=k)	return true;
	else 	return false;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)	cin>>l[i];
	cin>>k;
	if(n>=k){
		sort(l.begin(),l.end());
		reverse(l.begin(),l.end());
		cout<<l[k-1]<<endl;
		return 0;
	}
	double l=0,r=1000000000;
	while(r-l>1e-10){
		if(check((l+r)/2))	l=(l+r)/2;
		else 	r=(l+r)/2;
	}
	printf("%.15lf\n",(l+r)/2);
	return 0;
}
	
0