結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー keroberottekeroberotte
提出日時 2014-11-17 02:01:50
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 929 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 27,716 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-30 08:52:24
合計ジャッジ時間 2,917 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 20 ms
4,376 KB
testcase_03 AC 36 ms
4,376 KB
testcase_04 AC 47 ms
4,380 KB
testcase_05 AC 47 ms
4,380 KB
testcase_06 AC 47 ms
4,376 KB
testcase_07 AC 50 ms
4,376 KB
testcase_08 AC 50 ms
4,380 KB
testcase_09 AC 50 ms
4,376 KB
testcase_10 AC 42 ms
4,376 KB
testcase_11 AC 44 ms
4,380 KB
testcase_12 AC 41 ms
4,376 KB
testcase_13 AC 46 ms
4,380 KB
testcase_14 AC 48 ms
4,380 KB
testcase_15 AC 42 ms
4,376 KB
testcase_16 AC 47 ms
4,380 KB
testcase_17 AC 47 ms
4,380 KB
testcase_18 AC 46 ms
4,376 KB
testcase_19 AC 50 ms
4,376 KB
testcase_20 AC 50 ms
4,380 KB
testcase_21 AC 50 ms
4,376 KB
testcase_22 AC 42 ms
4,380 KB
testcase_23 AC 44 ms
4,380 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 9 ms
4,380 KB
testcase_29 AC 6 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int comp(const void *a, const void *b){
    if(*(int *)a < *(int *)b){
        return 1;
    }
    else if(*(int *)a == *(int *)b){
        return 0;
    }

    return -1;
}

double binary_search(int n, int x[], long long k){
    double l = 0, r = 1000000000;

    for(int aiueo = 0;aiueo < 75;aiueo++){
        long long current_num = 0;
        double mid = (l + r) / 2.0;

        for(int i = 0;i < n;i++){
            current_num += (int)(x[i] / mid);
        }

        if(k <= current_num){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    return l;
}

int main(){
    int n;
    long long k;
    int length[200000];

    scanf("%d", &n);


    for(int i = 0;i < n;i++){
        scanf("%d", &length[i]);
    }
    scanf("%lld", &k);
    printf("%f\n", binary_search(n, length, k));

    return 0;
}
0