結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tentententen
提出日時 2020-10-26 15:52:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 980 bytes
コンパイル時間 3,907 ms
コンパイル使用メモリ 71,208 KB
実行使用メモリ 65,716 KB
最終ジャッジ日時 2023-09-29 02:37:30
合計ジャッジ時間 34,843 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 837 ms
64,220 KB
testcase_01 AC 138 ms
55,768 KB
testcase_02 AC 885 ms
64,744 KB
testcase_03 AC 1,120 ms
65,332 KB
testcase_04 AC 1,306 ms
64,748 KB
testcase_05 AC 1,269 ms
64,656 KB
testcase_06 AC 1,215 ms
64,820 KB
testcase_07 AC 1,265 ms
64,896 KB
testcase_08 AC 1,255 ms
64,464 KB
testcase_09 AC 1,246 ms
64,724 KB
testcase_10 AC 1,167 ms
65,152 KB
testcase_11 AC 1,185 ms
64,720 KB
testcase_12 AC 1,284 ms
64,380 KB
testcase_13 AC 1,225 ms
65,052 KB
testcase_14 AC 1,172 ms
64,660 KB
testcase_15 AC 1,141 ms
64,432 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 805 ms
65,144 KB
testcase_19 AC 878 ms
64,376 KB
testcase_20 AC 891 ms
65,000 KB
testcase_21 AC 900 ms
64,876 KB
testcase_22 AC 761 ms
64,604 KB
testcase_23 AC 787 ms
64,568 KB
testcase_24 AC 129 ms
55,828 KB
testcase_25 AC 292 ms
59,932 KB
testcase_26 AC 222 ms
60,764 KB
testcase_27 AC 216 ms
56,424 KB
testcase_28 AC 527 ms
60,800 KB
testcase_29 AC 402 ms
60,484 KB
testcase_30 AC 300 ms
60,944 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[] sticks = new int[n];
        for (int i = 0; i < n; i++) {
            sticks[i] = sc.nextInt();
        }
        Arrays.sort(sticks);
        long k = sc.nextLong();
        if (n >= k) {
            System.out.println(sticks[n - (int)k]);
        } else {
            double left = sticks[0] / (double)(k / n + 1);
            double right = sticks[n - 1] + 1;
            for (int i = 0; i < 1000; i++) {
                double m = (left + right) / 2;
                long sum = 0;
                for (int j = 0; j < n; j++) {
                    sum += (long)(sticks[j] / m);
                }
                if (sum >= k) {
                    left = m;
                } else {
                    right = m;
                }
            }
            System.out.println(left);
        }
    }
}
0