結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー xuzijian629
提出日時 2018-11-02 01:19:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 746 bytes
コンパイル時間 2,386 ms
コンパイル使用メモリ 195,872 KB
実行使用メモリ 13,216 KB
最終ジャッジ日時 2025-03-03 11:20:34
合計ジャッジ時間 14,863 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(20);
    int n;
    cin >> n;
    vi ls(n);
    for (int i = 0; i < n; i++) {
        cin >> ls[i];
    }

    i64 k;
    cin >> k;

    auto ok = [&](double a) {
        i64 cnt = 0;
        for (i64 l: ls) {
            cnt += floor(l / a);
        }
        return cnt >= k;
    };

    double l = 0, r = 1e9 + 1;
    while (l < r - 1e-12) {
        double m = (l + r) / 2;
        if (ok(m)) {
            l = m;
        } else {
            r = m;
        }
    }
    cout << l << endl;
}
0