結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー data9824data9824
提出日時 2015-06-20 04:52:35
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 684 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 73,732 KB
実行使用メモリ 9,440 KB
最終ジャッジ日時 2023-09-21 10:32:45
合計ジャッジ時間 8,783 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
4,748 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 52 ms
4,380 KB
testcase_03 AC 98 ms
4,376 KB
testcase_04 AC 115 ms
4,740 KB
testcase_05 AC 114 ms
4,672 KB
testcase_06 AC 114 ms
4,580 KB
testcase_07 AC 134 ms
4,564 KB
testcase_08 AC 134 ms
4,524 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 <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;

const double EPS = 1E-10;

int main() {
	int n;
	cin >> n;
	vector<double> l(n);
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
	}
	long long k;
	cin >> k;
	double lower = 0, upper = *max_element(l.begin(), l.end());
	while (upper - lower > EPS || (upper - lower) / lower > EPS) {
		double length = (lower + upper) / 2.;
		long long count = 0;
		for (int i = 0; i < n; ++i) {
			count += (long long)floor(l[i] / length);
		}
		if (count >= k) {
			lower = length;
		} else {
			upper = length;
		}
	}
	cout << fixed << setprecision(20) << lower << endl;
	return 0;
}
0