結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー | kaito_tateyama |
提出日時 | 2019-03-06 12:50:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 118 ms / 5,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 772 ms |
コンパイル使用メモリ | 82,504 KB |
実行使用メモリ | 5,612 KB |
最終ジャッジ日時 | 2024-11-08 12:49:07 |
合計ジャッジ時間 | 4,756 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
#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; }