結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー fine
提出日時 2017-02-28 16:13:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 507 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 162,984 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2025-03-03 10:39:52
合計ジャッジ時間 4,162 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<double> L(n);
	for (int i = 0; i < n; i++) cin >> L[i];
	ll K;
	cin >> K;
	double ok = 0, ng = 1e9 + 1;
	for (int i = 0; i < 100; i++) {
		double mid = (ok + ng) / 2;
		ll cnt = 0;
		for (int j = 0; j < n; j++) {
			cnt += (ll)(L[j] / mid);
		}
		if (cnt >= K) ok = mid;
		else ng = mid;
	}
	cout << fixed << setprecision(10) << ok << endl;
	return 0;
}
0