結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー KtakuyaKtakuya
提出日時 2018-07-07 20:41:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,067 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 62,476 KB
実行使用メモリ 5,252 KB
最終ジャッジ日時 2023-09-18 14:49:33
合計ジャッジ時間 3,697 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
5,212 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 63 ms
4,592 KB
testcase_04 AC 65 ms
5,048 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 86 ms
5,084 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 58 ms
5,056 KB
testcase_11 WA -
testcase_12 AC 56 ms
4,848 KB
testcase_13 AC 79 ms
5,108 KB
testcase_14 AC 81 ms
5,112 KB
testcase_15 AC 73 ms
4,956 KB
testcase_16 AC 66 ms
5,060 KB
testcase_17 AC 66 ms
5,044 KB
testcase_18 WA -
testcase_19 AC 88 ms
5,208 KB
testcase_20 AC 91 ms
5,184 KB
testcase_21 AC 90 ms
5,032 KB
testcase_22 AC 63 ms
4,892 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 WA -
testcase_29 AC 8 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>

typedef long long int Int;
const Int MAX_INT = 1000000000;
const double EPS = 1e-9;

Int min(Int L[], Int N) {
	Int min_val = MAX_INT;
	for (Int i=0; i<N; i++) {
		if (min_val > L[i]) min_val = L[i];
	}
	return min_val;
}

Int sum(Int L[], Int N) {
	Int sum_val = 0;
	for (Int i=0; i<N; i++) sum_val += L[i];
	return sum_val;
}

bool retrievable(double x, Int L[], Int N, Int K) {
	Int max_num = 0;
	for (Int i=0; i<N; i++) {
		max_num += (Int)(L[i] / x);
	}
	return max_num >= K;
}

double find(double a, double b, Int L[], Int N, Int K) {
	if ((b - a) / a < EPS) {
		return a;
	} else {
		double c = (a + b) / 2;
		if (retrievable(c, L, N, K)) {
			return find(c, b, L, N, K);
		} else {
			return find(a, c, L, N, K);
		}
	}
}

int main() {
	Int N;
	std::cin >> N;
	Int L[N];
	for (Int i=0; i<N; i++)
		std::cin >> L[i];
	Int K;
	std::cin >> K;
	
	double a = (double)min(L, N) / (double)K;
	double b = (double)sum(L, N) / (K-0.1) ;
	
	std::cout << std::setprecision(9)
			<< find(a, b, L, N, K) << std::endl;
	
	return 0;
}
0