結果
問題 |
No.67 よくある棒を切る問題 (1)
|
ユーザー |
![]() |
提出日時 | 2015-06-20 04:52:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 684 bytes |
コンパイル時間 | 661 ms |
コンパイル使用メモリ | 76,112 KB |
実行使用メモリ | 8,604 KB |
最終ジャッジ日時 | 2025-03-03 10:19:34 |
合計ジャッジ時間 | 8,665 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 TLE * 1 -- * 20 |
ソースコード
#include <iostream> #include <cmath> #include <vector> #include <iomanip> #include <algorithm> using namespace std; const double EPS = 1E-10; int main() { int n; cin >> n; vector<double> l(n); for (int i = 0; i < n; ++i) { cin >> l[i]; } long long k; cin >> k; double lower = 0, upper = *max_element(l.begin(), l.end()); while (upper - lower > EPS || (upper - lower) / lower > EPS) { double length = (lower + upper) / 2.; long long count = 0; for (int i = 0; i < n; ++i) { count += (long long)floor(l[i] / length); } if (count >= k) { lower = length; } else { upper = length; } } cout << fixed << setprecision(20) << lower << endl; return 0; }