結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
4,744 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 35 ms
4,376 KB
testcase_03 AC 67 ms
4,380 KB
testcase_04 AC 70 ms
4,592 KB
testcase_05 AC 71 ms
4,556 KB
testcase_06 AC 71 ms
4,556 KB
testcase_07 AC 91 ms
4,900 KB
testcase_08 AC 91 ms
4,712 KB
testcase_09 AC 326 ms
4,704 KB
testcase_10 AC 64 ms
4,444 KB
testcase_11 AC 67 ms
4,588 KB
testcase_12 AC 61 ms
4,380 KB
testcase_13 AC 84 ms
4,504 KB
testcase_14 AC 86 ms
4,612 KB
testcase_15 AC 277 ms
4,380 KB
testcase_16 AC 307 ms
4,704 KB
testcase_17 AC 306 ms
4,752 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 327 ms
4,756 KB
testcase_22 AC 61 ms
4,500 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 16 ms
4,376 KB
testcase_29 AC 9 ms
4,384 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;
	L = 1.0/L;
	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 = *max_element(l.begin(), l.end());
	
	const double EPS = 1e-10;

	int count = 0;
	while( fabs(ub - lb) > EPS){
		count++;
		
		if(count > 1100){
			break;
		}
		double med = (lb+ub)*0.5;
		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