結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tentententen
提出日時 2020-10-26 16:50:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 981 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 72,800 KB
実行使用メモリ 67,524 KB
最終ジャッジ日時 2023-09-29 02:40:37
合計ジャッジ時間 67,368 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 811 ms
66,424 KB
testcase_01 AC 140 ms
56,148 KB
testcase_02 AC 1,900 ms
64,848 KB
testcase_03 AC 3,112 ms
66,496 KB
testcase_04 AC 3,977 ms
64,856 KB
testcase_05 AC 3,927 ms
64,684 KB
testcase_06 AC 3,995 ms
65,196 KB
testcase_07 AC 4,006 ms
65,224 KB
testcase_08 AC 3,980 ms
64,728 KB
testcase_09 AC 3,997 ms
64,760 KB
testcase_10 AC 3,634 ms
64,620 KB
testcase_11 AC 3,839 ms
63,240 KB
testcase_12 AC 3,519 ms
65,144 KB
testcase_13 AC 3,712 ms
64,748 KB
testcase_14 AC 3,832 ms
64,892 KB
testcase_15 AC 3,506 ms
63,204 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 773 ms
64,664 KB
testcase_19 AC 851 ms
64,296 KB
testcase_20 AC 878 ms
65,224 KB
testcase_21 AC 887 ms
65,360 KB
testcase_22 AC 729 ms
67,524 KB
testcase_23 AC 765 ms
64,560 KB
testcase_24 AC 130 ms
55,992 KB
testcase_25 AC 364 ms
60,360 KB
testcase_26 AC 263 ms
59,228 KB
testcase_27 AC 230 ms
57,228 KB
testcase_28 AC 941 ms
60,564 KB
testcase_29 AC 645 ms
60,544 KB
testcase_30 AC 388 ms
60,812 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 < 10000; 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