結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー BucchimanBucchiman
提出日時 2020-08-19 16:31:14
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 31,232 KB
実行使用メモリ 10,272 KB
最終ジャッジ日時 2024-04-20 09:32:16
合計ジャッジ時間 7,931 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/*
 * FileName:     code
 * CreatedDate:  2020-08-19 16:15:34 +0900
 * LastModified: 2020-08-19 16:29:57 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#define l_max 1e9
#define error 1e-9

int C(double *L, int N, int K, double middle){
    int num = 0;
    for(int i=0; i<N; i++){
        num += (int)(L[i]/middle);
    }
    if(K>num){
        return 1;
    }
    else{
        return 0;
    }
}


int main(void){
    int N;scanf("%d", &N);
    double *L = malloc(N*sizeof(double));
    for(int i=0; i<N; i++)scanf("%lf", L+i);
    int K;scanf("%d", &K);
    double left = 0, right = l_max;
    for(int i=0; i<100; i++){
//        double left = 0, right = l_max;
        while(left + error < right){
            double middle = (left + right)/2;
            if(C(L, N, K, middle)){
                right = middle;
            }
            else{
                left = middle;
            }
        }
    }
    printf("%lf\n", right);
    return 0;
}
0