結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー Lay_ecLay_ec
提出日時 2014-11-16 23:58:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 769 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 77,332 KB
実行使用メモリ 9,204 KB
最終ジャッジ日時 2023-08-30 08:13:57
合計ジャッジ時間 9,213 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
4,648 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
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 <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>

using namespace std; 


int main(){

	long n,k;
	cin>>n;

	vector<long> L(n);

	for(long i=0;i<n;i++) cin>>L[i];
	cin>>k;

	sort(L.begin(),L.end());

	if(n>=k) cout<<L[n-k];
	else{
		double res=0;

		double l=0,r=L[n-1];

		while((r-l)>1e-10){
			unsigned long long num=0;

			double m=(l+r)/2.0;
			for(long i=0;i<n;i++) num+=floor(L[i]/m);

//			cout<<"m="<<m<<"->"<<num<<endl;

			if(num<k) r=m;
			else{
				res=max(res,m);
				l=m;
			}

		}
		cout<<res<<endl;
	}

	return 0;
}
0