結果

問題 No.5 数字のブロック
ユーザー tokustokus
提出日時 2021-11-15 23:13:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,108 bytes
コンパイル時間 3,243 ms
コンパイル使用メモリ 77,780 KB
実行使用メモリ 54,476 KB
最終ジャッジ日時 2023-08-21 18:17:15
合計ジャッジ時間 7,558 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
50,780 KB
testcase_01 AC 61 ms
50,612 KB
testcase_02 WA -
testcase_03 AC 99 ms
53,444 KB
testcase_04 AC 78 ms
52,620 KB
testcase_05 AC 102 ms
54,232 KB
testcase_06 AC 88 ms
53,132 KB
testcase_07 AC 78 ms
51,424 KB
testcase_08 AC 96 ms
53,716 KB
testcase_09 AC 73 ms
52,576 KB
testcase_10 AC 104 ms
53,988 KB
testcase_11 AC 79 ms
52,048 KB
testcase_12 AC 98 ms
53,520 KB
testcase_13 AC 103 ms
54,232 KB
testcase_14 AC 61 ms
50,644 KB
testcase_15 AC 64 ms
50,724 KB
testcase_16 AC 102 ms
53,960 KB
testcase_17 AC 117 ms
54,036 KB
testcase_18 AC 122 ms
53,900 KB
testcase_19 AC 123 ms
54,476 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 59 ms
50,656 KB
testcase_24 AC 64 ms
51,432 KB
testcase_25 AC 67 ms
51,736 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 80 ms
51,560 KB
testcase_30 AC 74 ms
52,344 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;

class Main {
    public static void main(String[] args) {
        no5();
    }

    // No.5 数字のブロック
    private static void no5() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        // 箱の幅
        String l;
        // ブロックの数
        String n;
        // 各ブロックの幅
        String block;

        try {
            l = reader.readLine();
            n = reader.readLine();
            block = reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        int[] numbers = Stream.of(block.split(" ")).mapToInt(Integer::parseInt).sorted().toArray();

        int width = Integer.parseInt(l);

        int max = 0;

        for (int i : numbers) {
            if (i <= width) {
                width -= i;
                max++;
            } else {
                System.out.println(max);
                break;
            };
        }
    }
}
0