結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー data9824data9824
提出日時 2015-06-20 05:13:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 140 ms / 5,000 ms
コード長 774 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 74,752 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 23:25:29
合計ジャッジ時間 4,792 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 56 ms
6,940 KB
testcase_03 AC 100 ms
6,944 KB
testcase_04 AC 117 ms
6,940 KB
testcase_05 AC 114 ms
6,944 KB
testcase_06 AC 118 ms
6,940 KB
testcase_07 AC 134 ms
6,940 KB
testcase_08 AC 135 ms
6,940 KB
testcase_09 AC 140 ms
6,940 KB
testcase_10 AC 107 ms
6,944 KB
testcase_11 AC 110 ms
6,944 KB
testcase_12 AC 98 ms
6,944 KB
testcase_13 AC 123 ms
6,944 KB
testcase_14 AC 129 ms
6,944 KB
testcase_15 AC 121 ms
6,940 KB
testcase_16 AC 115 ms
6,940 KB
testcase_17 AC 114 ms
6,944 KB
testcase_18 AC 110 ms
6,944 KB
testcase_19 AC 128 ms
6,944 KB
testcase_20 AC 132 ms
6,940 KB
testcase_21 AC 134 ms
6,944 KB
testcase_22 AC 102 ms
6,940 KB
testcase_23 AC 102 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 4 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 23 ms
6,944 KB
testcase_29 AC 12 ms
6,940 KB
testcase_30 AC 4 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

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());
	double preLength = 0.0;
	while (upper - lower > EPS || (upper - lower) / lower > EPS) {
		double length = (lower + upper) / 2.;
		if (length == preLength) {
			break;
		}
		preLength = length;
		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