結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー maine_honzukimaine_honzuki
提出日時 2020-05-10 16:52:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 164,208 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 01:05:20
合計ジャッジ時間 5,881 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 54 ms
6,944 KB
testcase_03 AC 99 ms
6,940 KB
testcase_04 AC 114 ms
6,940 KB
testcase_05 AC 115 ms
6,940 KB
testcase_06 AC 115 ms
6,944 KB
testcase_07 AC 138 ms
6,944 KB
testcase_08 AC 138 ms
6,944 KB
testcase_09 AC 140 ms
6,940 KB
testcase_10 AC 103 ms
6,944 KB
testcase_11 AC 109 ms
6,944 KB
testcase_12 AC 101 ms
6,940 KB
testcase_13 AC 128 ms
6,940 KB
testcase_14 AC 132 ms
6,940 KB
testcase_15 AC 119 ms
6,940 KB
testcase_16 AC 116 ms
6,940 KB
testcase_17 AC 115 ms
6,944 KB
testcase_18 AC 116 ms
6,944 KB
testcase_19 AC 139 ms
6,940 KB
testcase_20 AC 141 ms
6,944 KB
testcase_21 AC 140 ms
6,940 KB
testcase_22 AC 105 ms
6,940 KB
testcase_23 AC 109 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 5 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 25 ms
6,944 KB
testcase_29 AC 14 ms
6,944 KB
testcase_30 AC 5 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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