結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー | focus |
提出日時 | 2018-01-12 15:38:56 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,751 ms / 5,000 ms |
コード長 | 627 bytes |
コンパイル時間 | 694 ms |
コンパイル使用メモリ | 62,900 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-08 12:35:58 |
合計ジャッジ時間 | 32,950 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
#include<iostream> #include<algorithm> #include<vector> #include<cstdio> using namespace std; typedef long long ll; ll K; vector<ll> L; bool split(double num){ ll eda=0; for(int i=0;i<L.size();i++){ eda+=L[i]/num; } if(eda>=K) return true; return false; } int main(){ double lb=0,ub=0,mid; ll N,x; cin >> N; while(N--){ cin >> x; L.push_back(x); if(ub<x) ub = x; } cin >> K; int limit=1000; do{ mid=(lb+ub)/2; if(split(mid)) lb=mid; else ub=mid; }while(limit--); printf("%.10lf\n",lb); return 0; }