結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー koyumeishikoyumeishi
提出日時 2014-11-16 23:35:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 73,896 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-08-30 07:37:04
合計ジャッジ時間 7,176 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
4,736 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 38 ms
4,380 KB
testcase_03 AC 71 ms
4,376 KB
testcase_04 AC 76 ms
4,684 KB
testcase_05 AC 76 ms
4,736 KB
testcase_06 AC 76 ms
4,560 KB
testcase_07 AC 96 ms
4,876 KB
testcase_08 AC 96 ms
4,672 KB
testcase_09 AC 397 ms
4,732 KB
testcase_10 AC 69 ms
4,412 KB
testcase_11 AC 73 ms
4,728 KB
testcase_12 AC 66 ms
4,472 KB
testcase_13 AC 88 ms
4,380 KB
testcase_14 AC 92 ms
4,728 KB
testcase_15 AC 338 ms
4,380 KB
testcase_16 AC 377 ms
4,736 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 17 ms
4,380 KB
testcase_29 AC 10 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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;

	int count = 0;
	while(ub - lb > EPS){
		count++;
		
		if(count > 1000){
			break;
		}
		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