結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tentententen
提出日時 2021-03-08 09:04:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,210 ms / 5,000 ms
コード長 890 bytes
コンパイル時間 2,446 ms
コンパイル使用メモリ 75,344 KB
実行使用メモリ 69,740 KB
最終ジャッジ日時 2024-04-26 01:19:48
合計ジャッジ時間 30,307 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 882 ms
68,888 KB
testcase_01 AC 137 ms
54,384 KB
testcase_02 AC 777 ms
60,964 KB
testcase_03 AC 1,049 ms
69,532 KB
testcase_04 AC 1,108 ms
69,740 KB
testcase_05 AC 1,114 ms
69,688 KB
testcase_06 AC 1,049 ms
69,056 KB
testcase_07 AC 1,195 ms
68,740 KB
testcase_08 AC 1,210 ms
68,524 KB
testcase_09 AC 1,181 ms
69,392 KB
testcase_10 AC 1,043 ms
69,488 KB
testcase_11 AC 1,068 ms
69,332 KB
testcase_12 AC 959 ms
69,072 KB
testcase_13 AC 1,201 ms
69,192 KB
testcase_14 AC 1,189 ms
69,148 KB
testcase_15 AC 1,125 ms
69,584 KB
testcase_16 AC 885 ms
68,664 KB
testcase_17 AC 852 ms
68,352 KB
testcase_18 AC 892 ms
68,332 KB
testcase_19 AC 976 ms
68,424 KB
testcase_20 AC 908 ms
68,708 KB
testcase_21 AC 956 ms
69,188 KB
testcase_22 AC 839 ms
64,952 KB
testcase_23 AC 863 ms
68,192 KB
testcase_24 AC 133 ms
54,284 KB
testcase_25 AC 244 ms
57,820 KB
testcase_26 AC 215 ms
56,956 KB
testcase_27 AC 209 ms
54,896 KB
testcase_28 AC 514 ms
59,748 KB
testcase_29 AC 374 ms
59,552 KB
testcase_30 AC 252 ms
58,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] pieces = new int[n];
        for (int i = 0; i < n; i++) {
            pieces[i] = sc.nextInt();
        }
        Arrays.sort(pieces);
        long k = sc.nextLong();
        double min = pieces[n - 1] / (double)k;
        double max = pieces[n - 1] + 1;
        for (int i = 0; i < 100; i++) {
            double m = (min + max) / 2;
            long count = 0;
            for (int j = n - 1; j >= 0 && count < k && pieces[j] >= m; j--) {
                count += (long)(pieces[j] / m);
            }
            if (count >= k) {
                min = m;
            } else {
                max = m;
            }
        }
        System.out.println(java.math.BigDecimal.valueOf(min).toPlainString());
    }
}
0