結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー koyumeishikoyumeishi
提出日時 2014-11-16 23:32:33
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 820 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 73,492 KB
実行使用メモリ 9,348 KB
最終ジャッジ日時 2023-08-30 07:32:40
合計ジャッジ時間 8,530 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
4,540 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 38 ms
4,380 KB
testcase_03 AC 71 ms
4,376 KB
testcase_04 AC 76 ms
4,588 KB
testcase_05 AC 77 ms
4,548 KB
testcase_06 AC 76 ms
4,764 KB
testcase_07 AC 97 ms
4,548 KB
testcase_08 AC 97 ms
4,596 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 <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

long long cut(vector<long long> &l, double L){
	long long ret = 0;
	for(int i=0; i<l.size(); i++){
		long long tmp = l[i]/L + 1e-9;
		ret += tmp;
	}
	return ret;
}

double bs(vector<long long> &l, long long K){
	double lb = 0;
	double ub = 1e+9;
	const double EPS = 1e-10;
	while(ub - lb > EPS){
		double med = (lb+ub)/2.0;
		long long tmp = cut(l, med);
		if( tmp < K ){
			ub = med;
		}else{
			lb = med;
		}
	}
	return ub;
}

int main(){
	int n;
	cin >> n;
	vector<long long> l(n);
	for(int i=0; i<n; i++) cin >> l[i];
	long long k;
	cin >> k;
	printf("%.10f\n", bs(l,k));
	return 0;
}
0