結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
![]() |
提出日時 | 2020-05-09 01:54:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 377 ms / 5,000 ms |
コード長 | 913 bytes |
コンパイル時間 | 690 ms |
コンパイル使用メモリ | 76,588 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-03-03 11:39:23 |
合計ジャッジ時間 | 10,160 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <list> #include <queue> #include <cmath> #include <algorithm> #define rep(i, n) for(i = 0; i < (n); i++) #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define MOD 1000000007 #define PI 3.14159265358979323846 #define INF 1 << 30 using namespace std; typedef long long ll; typedef pair<int, int> pp; double Search(double l, double r, const ll k, vector<double> & d, int s) { if (s == 200) return l; s++; double p = (l + r) / 2.0; ll i, sum = 0; rep(i, d.size()) sum += d[i] / p; if (sum >= k) return Search(p, r, k, d, s); else return Search(l, p, k, d, s); } int main(void) { ll num, i, k; double ans, ma = 0; cin >> num; vector<double> d(num); rep(i, num) { cin >> d[i]; chmax(ma, d[i]); } cin >> k; ans = Search(0.0, ma * (double)num / (double)k, k, d, 0); printf("%.15lf\n", ans); return 0; }