結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
![]() |
提出日時 | 2019-03-06 12:50:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 121 ms / 5,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 979 ms |
コンパイル使用メモリ | 80,708 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-03-03 11:21:24 |
合計ジャッジ時間 | 4,930 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define P(x) cout << (x) << "\n" #define D(x) cerr << (x) << "\n" #define fcout cout << fixed << setprecision(18) using i64 = long long int; // 10^18 static const double eps = (1e-10); vector<double> l; i64 k; bool isOK(double s) { double sum = 0; for (auto ll : l) { sum += (i64)floor(ll / s); } return sum >= k; } double binary_search() { double ng = 0; double ok = 10000000000; int i=0; while (i<100) { double mid = ng + (double (ok - ng)) / 2; if (!isOK(mid)) { ok = mid; } else { ng = mid; } i++; } return ok; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; REP(i, n) { double ll; cin >> ll; l.push_back(ll); } cin >> k; fcout<< binary_search() <<endl; return 0; }