結果

問題 No.5 数字のブロック
ユーザー mobius_bkstmobius_bkst
提出日時 2015-04-22 23:20:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 980 bytes
コンパイル時間 4,917 ms
コンパイル使用メモリ 74,692 KB
実行使用メモリ 53,032 KB
最終ジャッジ日時 2023-08-11 08:16:16
合計ジャッジ時間 8,974 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,548 KB
testcase_01 AC 46 ms
49,476 KB
testcase_02 AC 44 ms
49,480 KB
testcase_03 AC 78 ms
51,516 KB
testcase_04 AC 66 ms
51,676 KB
testcase_05 AC 92 ms
52,484 KB
testcase_06 AC 75 ms
52,008 KB
testcase_07 AC 71 ms
51,964 KB
testcase_08 AC 94 ms
52,904 KB
testcase_09 AC 58 ms
50,952 KB
testcase_10 AC 93 ms
52,712 KB
testcase_11 AC 68 ms
51,552 KB
testcase_12 AC 82 ms
52,144 KB
testcase_13 AC 93 ms
52,592 KB
testcase_14 AC 48 ms
49,312 KB
testcase_15 AC 48 ms
49,388 KB
testcase_16 AC 95 ms
52,872 KB
testcase_17 AC 88 ms
53,032 KB
testcase_18 AC 89 ms
52,372 KB
testcase_19 AC 99 ms
52,880 KB
testcase_20 AC 45 ms
49,444 KB
testcase_21 AC 45 ms
49,432 KB
testcase_22 AC 45 ms
49,300 KB
testcase_23 AC 46 ms
49,820 KB
testcase_24 AC 50 ms
49,592 KB
testcase_25 AC 51 ms
49,396 KB
testcase_26 AC 46 ms
49,768 KB
testcase_27 AC 45 ms
49,300 KB
testcase_28 AC 46 ms
49,816 KB
testcase_29 AC 66 ms
51,616 KB
testcase_30 AC 63 ms
51,476 KB
testcase_31 AC 45 ms
49,384 KB
testcase_32 AC 46 ms
49,444 KB
testcase_33 AC 46 ms
49,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No005 {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    System.in));
            int L = Integer.parseInt(br.readLine());
            int N = Integer.parseInt(br.readLine());
            String[] WStrArray = br.readLine().split(" ");

            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = Integer.parseInt(WStrArray[i]);
            }
            Arrays.sort(W);

            int count = 0;
            for (int i = 0; i < N; i++) {
                L = L - W[i];
                if (L < 0) {
                    break;
                }
                count++;
            }

            System.out.println(count);
        } catch (Exception e) {
            System.err.println("Error:" + e.getMessage());
        }
    }

}
0