結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー masamasa
提出日時 2015-02-15 02:27:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 163 ms / 5,000 ms
コード長 622 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 61,260 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 23:15:20
合計ジャッジ時間 5,687 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 62 ms
6,940 KB
testcase_03 AC 119 ms
6,940 KB
testcase_04 AC 144 ms
6,940 KB
testcase_05 AC 147 ms
6,940 KB
testcase_06 AC 137 ms
6,944 KB
testcase_07 AC 163 ms
6,944 KB
testcase_08 AC 158 ms
6,944 KB
testcase_09 AC 152 ms
6,944 KB
testcase_10 AC 131 ms
6,944 KB
testcase_11 AC 138 ms
6,940 KB
testcase_12 AC 118 ms
6,940 KB
testcase_13 AC 148 ms
6,944 KB
testcase_14 AC 152 ms
6,940 KB
testcase_15 AC 130 ms
6,940 KB
testcase_16 AC 125 ms
6,944 KB
testcase_17 AC 124 ms
6,940 KB
testcase_18 AC 121 ms
6,940 KB
testcase_19 AC 141 ms
6,940 KB
testcase_20 AC 142 ms
6,944 KB
testcase_21 AC 140 ms
6,944 KB
testcase_22 AC 107 ms
6,944 KB
testcase_23 AC 112 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 5 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 27 ms
6,944 KB
testcase_29 AC 15 ms
6,940 KB
testcase_30 AC 5 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

const double EPS = 1e-9;

using namespace std;

int main() {
	int n;
	long long k;

	cin >> n;
	vector<double> l(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	cin >> k;

	double upper = 1e9;
	double lower = 0;
	double mid;

	long long count;
	while (upper - lower > EPS && upper > lower * (EPS + 1)) {
		mid = (upper + lower) / 2;
		count = 0;
		for (int i = 0; i < n; i++) {
			count += l[i] / mid;
		}

		if (count >= k) {
			lower = mid;
		} else {
			upper = mid;
		}
	}

	printf("%.10f\n", mid);
	return 0;
}
0