結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー plasma_e
提出日時 2019-01-17 21:32:13
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 173 ms / 5,000 ms
コード長 662 bytes
コンパイル時間 6,452 ms
コンパイル使用メモリ 133,964 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-03-03 11:21:32
合計ジャッジ時間 11,582 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<iomanip>

int main()
{
	std::cout << std::setprecision(15);
	int N;
	std::cin >> N;
	std::vector<double> L(N);
	for (auto& v : L)
	{
		std::cin >> v;
	}
	std::int64_t K;
	std::cin >> K;
	double min = 0;
	double max = *std::max_element(L.begin(), L.end());
	for (int i = 0; i < 200; ++i)
	{
		auto mid = (min + max) / 2;
		std::int64_t c = 0;
		for (auto const& v : L)
		{
			c += std::int64_t(v / mid);
		}
		if (c >= K)
		{
			min = mid;
		}
		else
		{
			max = mid;
		}
	}
	std::cout << min << std::endl;
}
0