結果

問題 No.5 数字のブロック
ユーザー tokustokus
提出日時 2021-11-15 23:11:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,107 bytes
コンパイル時間 4,045 ms
コンパイル使用メモリ 77,400 KB
実行使用メモリ 54,456 KB
最終ジャッジ日時 2023-08-21 18:15:31
合計ジャッジ時間 7,966 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
50,928 KB
testcase_01 AC 57 ms
50,620 KB
testcase_02 WA -
testcase_03 AC 94 ms
53,384 KB
testcase_04 AC 76 ms
52,768 KB
testcase_05 WA -
testcase_06 AC 85 ms
52,840 KB
testcase_07 AC 77 ms
51,444 KB
testcase_08 AC 94 ms
53,340 KB
testcase_09 AC 71 ms
52,940 KB
testcase_10 AC 99 ms
53,820 KB
testcase_11 AC 78 ms
51,992 KB
testcase_12 AC 95 ms
53,584 KB
testcase_13 AC 101 ms
53,940 KB
testcase_14 AC 58 ms
50,496 KB
testcase_15 WA -
testcase_16 AC 98 ms
53,488 KB
testcase_17 AC 116 ms
53,736 KB
testcase_18 AC 113 ms
54,052 KB
testcase_19 AC 117 ms
54,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 58 ms
50,556 KB
testcase_24 AC 60 ms
50,584 KB
testcase_25 AC 64 ms
51,520 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
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