結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー maine_honzuki
提出日時 2020-05-10 16:52:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 152 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 1,562 ms
コンパイル使用メモリ 161,860 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-03-03 11:39:26
合計ジャッジ時間 6,011 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, L[200020];
    long long K;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    cin >> K;

    auto check = [&](long double l) {
        long long cnt = 0;
        for (int i = 0; i < N; i++) {
            cnt += (int)(L[i] / l);
        }
        return cnt >= K;
    };

    const long double eps = 1e-10;
    long double ok = 0;
    long double ng = 10000000001;
    while (abs(ok - ng) > eps) {
        long double mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << fixed << setprecision(10) << ok << endl;
}
0