結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tottoripapertottoripaper
提出日時 2014-11-16 23:52:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 416 ms / 5,000 ms
コード長 568 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 54,184 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 23:08:56
合計ジャッジ時間 10,966 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 416 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 156 ms
6,940 KB
testcase_03 AC 299 ms
6,940 KB
testcase_04 AC 389 ms
6,940 KB
testcase_05 AC 386 ms
6,944 KB
testcase_06 AC 387 ms
6,944 KB
testcase_07 AC 408 ms
6,944 KB
testcase_08 AC 410 ms
6,940 KB
testcase_09 AC 407 ms
6,940 KB
testcase_10 AC 343 ms
6,944 KB
testcase_11 AC 365 ms
6,944 KB
testcase_12 AC 336 ms
6,940 KB
testcase_13 AC 378 ms
6,944 KB
testcase_14 AC 389 ms
6,940 KB
testcase_15 AC 349 ms
6,944 KB
testcase_16 AC 382 ms
6,944 KB
testcase_17 AC 381 ms
6,944 KB
testcase_18 AC 381 ms
6,940 KB
testcase_19 AC 404 ms
6,940 KB
testcase_20 AC 406 ms
6,940 KB
testcase_21 AC 405 ms
6,940 KB
testcase_22 AC 349 ms
6,944 KB
testcase_23 AC 368 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 9 ms
6,940 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 4 ms
6,944 KB
testcase_28 AC 69 ms
6,940 KB
testcase_29 AC 35 ms
6,940 KB
testcase_30 AC 10 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>

typedef long long ll;

int N;
ll K;
double L[200000];

bool can(double x){
    ll k = 0;
    for(int i=0;i<N;i++){
        k += static_cast<int>(L[i] / x);
    }

    return k >= K;
}

int main(){
    std::cin >> N;

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

    std::cin >> K;

    double lb = 0.0, ub = 1000000100.0;
    for(int i=0;i<1000;i++){
        double mid = (lb+ub) / 2.0;
        if(can(mid)){lb = mid;}
        else{ub = mid;}
    }

    printf("%.30f\n", lb);
}
0