結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tottoripapertottoripaper
提出日時 2014-11-16 23:52:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 411 ms / 5,000 ms
コード長 568 bytes
コンパイル時間 1,203 ms
コンパイル使用メモリ 51,876 KB
実行使用メモリ 5,296 KB
最終ジャッジ日時 2023-08-08 05:34:39
合計ジャッジ時間 12,038 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 411 ms
5,220 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 153 ms
4,376 KB
testcase_03 AC 291 ms
4,676 KB
testcase_04 AC 382 ms
5,228 KB
testcase_05 AC 381 ms
5,284 KB
testcase_06 AC 382 ms
5,248 KB
testcase_07 AC 404 ms
5,100 KB
testcase_08 AC 403 ms
5,100 KB
testcase_09 AC 405 ms
5,108 KB
testcase_10 AC 344 ms
5,072 KB
testcase_11 AC 366 ms
5,024 KB
testcase_12 AC 332 ms
4,952 KB
testcase_13 AC 369 ms
5,088 KB
testcase_14 AC 382 ms
5,196 KB
testcase_15 AC 342 ms
4,880 KB
testcase_16 AC 382 ms
5,104 KB
testcase_17 AC 382 ms
5,096 KB
testcase_18 AC 387 ms
5,156 KB
testcase_19 AC 403 ms
5,104 KB
testcase_20 AC 403 ms
5,296 KB
testcase_21 AC 402 ms
5,240 KB
testcase_22 AC 345 ms
4,940 KB
testcase_23 AC 365 ms
5,160 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 9 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 65 ms
4,384 KB
testcase_29 AC 33 ms
4,380 KB
testcase_30 AC 10 ms
4,376 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