結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 236 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 81 ms
6,944 KB
testcase_03 AC 158 ms
6,944 KB
testcase_04 AC 199 ms
6,944 KB
testcase_05 AC 202 ms
6,940 KB
testcase_06 AC 207 ms
6,940 KB
testcase_07 AC 221 ms
6,940 KB
testcase_08 AC 217 ms
6,944 KB
testcase_09 AC 222 ms
6,940 KB
testcase_10 AC 179 ms
6,940 KB
testcase_11 AC 192 ms
6,940 KB
testcase_12 AC 178 ms
6,940 KB
testcase_13 AC 203 ms
6,940 KB
testcase_14 AC 213 ms
6,944 KB
testcase_15 AC 188 ms
6,940 KB
testcase_16 AC 202 ms
6,940 KB
testcase_17 AC 201 ms
6,940 KB
testcase_18 AC 202 ms
6,944 KB
testcase_19 AC 221 ms
6,944 KB
testcase_20 AC 222 ms
6,940 KB
testcase_21 AC 222 ms
6,940 KB
testcase_22 AC 182 ms
6,940 KB
testcase_23 AC 194 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 6 ms
6,944 KB
testcase_26 AC 3 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 37 ms
6,940 KB
testcase_29 AC 20 ms
6,944 KB
testcase_30 AC 6 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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;
	for (int i = 0; i < 100; i++) {
		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