結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー vrjfsyivrjfsyi
提出日時 2018-04-02 07:59:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 771 bytes
コンパイル時間 841 ms
コンパイル使用メモリ 67,196 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 00:27:32
合計ジャッジ時間 4,401 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 43 ms
6,944 KB
testcase_03 AC 82 ms
6,940 KB
testcase_04 AC 90 ms
6,944 KB
testcase_05 AC 89 ms
6,940 KB
testcase_06 AC 89 ms
6,940 KB
testcase_07 AC 112 ms
6,944 KB
testcase_08 AC 112 ms
6,944 KB
testcase_09 AC 112 ms
6,940 KB
testcase_10 AC 79 ms
6,944 KB
testcase_11 AC 85 ms
6,940 KB
testcase_12 AC 78 ms
6,940 KB
testcase_13 AC 102 ms
6,940 KB
testcase_14 AC 107 ms
6,940 KB
testcase_15 AC 96 ms
6,940 KB
testcase_16 AC 90 ms
6,940 KB
testcase_17 AC 90 ms
6,940 KB
testcase_18 AC 89 ms
6,940 KB
testcase_19 AC 112 ms
6,940 KB
testcase_20 AC 112 ms
6,944 KB
testcase_21 AC 112 ms
6,944 KB
testcase_22 AC 80 ms
6,944 KB
testcase_23 AC 86 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 20 ms
6,940 KB
testcase_29 AC 11 ms
6,944 KB
testcase_30 AC 4 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;

long ls[200000];

long f(double x, int N) {
    long count = 0;
    for (int i = 0; i < N; ++i) {
        count += (long) (ls[i] / x);
    }
    return count;
}


int main() {

    int N;
    cin >> N;


    long L;
    for (int i = 0; i < N; ++i) {
        cin >> L;
        ls[i] = L;
    }

    long K;
    cin >> K;

    double a = 0;
    double b = 1000000000;

    double x;
    for (int j = 0; j < 100; ++j) {

        x = (a + b) / 2;

        if (f(x, N) >= K) {
            a = x;
        } else {
            b = x;
        }
    }

    printf("%.14f\n", x);

    return 0;
}

0