結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー fiordfiord
提出日時 2015-08-06 00:30:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 553 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 148,668 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 04:05:23
合計ジャッジ時間 6,454 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 59 ms
4,376 KB
testcase_03 AC 110 ms
4,376 KB
testcase_04 AC 131 ms
4,380 KB
testcase_05 AC 130 ms
4,380 KB
testcase_06 AC 132 ms
4,380 KB
testcase_07 AC 149 ms
4,376 KB
testcase_08 AC 151 ms
4,376 KB
testcase_09 AC 150 ms
4,376 KB
testcase_10 AC 118 ms
4,380 KB
testcase_11 AC 124 ms
4,376 KB
testcase_12 AC 114 ms
4,376 KB
testcase_13 AC 139 ms
4,380 KB
testcase_14 AC 143 ms
4,376 KB
testcase_15 AC 129 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 68 ms
4,376 KB
testcase_19 AC 89 ms
4,376 KB
testcase_20 AC 89 ms
4,376 KB
testcase_21 AC 89 ms
4,376 KB
testcase_22 AC 62 ms
4,380 KB
testcase_23 AC 65 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 5 ms
4,376 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 26 ms
4,380 KB
testcase_29 AC 14 ms
4,376 KB
testcase_30 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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-9){
		if(check((l+r)/2))	l=(l+r)/2;
		else 	r=(l+r)/2;
	}
	printf("%.15lf\n",r);
	return 0;
}
	
0