結果
| 問題 | No.67 よくある棒を切る問題 (1) | 
| コンテスト | |
| ユーザー |  ふーらくたる | 
| 提出日時 | 2016-08-13 03:46:39 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 171 ms / 5,000 ms | 
| コード長 | 907 bytes | 
| コンパイル時間 | 705 ms | 
| コンパイル使用メモリ | 79,616 KB | 
| 実行使用メモリ | 8,608 KB | 
| 最終ジャッジ日時 | 2025-03-03 10:35:42 | 
| 合計ジャッジ時間 | 5,179 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 30 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
const double kEPS = 1e-10;
int N;
ll K;
vector<int> L;
bool C(double x) {
    ll num = 0;
    for (int i = 0; i < N; i++) {
        num += floor((double)L[i] / x + kEPS);
        if (num >= K) return true;
    }
    return false;
}
void Solve() {
    sort(L.begin(), L.end(), greater<double>());
    double lb = 0.0, ub = 2e20;
    for (int i = 0; i < 100; i++) {
        double mid = (lb + ub) / 2.0;
        if (C(mid)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    cout << fixed << setprecision(20) << lb << endl;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    L = vector<int>(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    cin >> K;
    Solve();
    return 0;
}
            
            
            
        