結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー Lay_ecLay_ec
提出日時 2014-11-17 00:11:37
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 81,232 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-01 19:55:15
合計ジャッジ時間 5,413 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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 l=0,r=L[n-1],m;

		for(int i=0;i<100;i++){
			long num=0;

			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{
				l=m;
			}

		}
		printf("%.16f\n",m);
	}

	return 0;
}
0