結果

問題 No.5 数字のブロック
ユーザー mobius_bkstmobius_bkst
提出日時 2015-04-22 23:20:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 112 ms / 5,000 ms
コード長 980 bytes
コンパイル時間 3,854 ms
コンパイル使用メモリ 76,060 KB
実行使用メモリ 52,444 KB
最終ジャッジ日時 2024-04-29 00:50:51
合計ジャッジ時間 7,411 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
49,960 KB
testcase_01 AC 55 ms
50,112 KB
testcase_02 AC 55 ms
50,332 KB
testcase_03 AC 90 ms
52,000 KB
testcase_04 AC 93 ms
51,164 KB
testcase_05 AC 97 ms
52,408 KB
testcase_06 AC 83 ms
51,416 KB
testcase_07 AC 84 ms
51,360 KB
testcase_08 AC 91 ms
51,956 KB
testcase_09 AC 65 ms
50,596 KB
testcase_10 AC 108 ms
52,444 KB
testcase_11 AC 88 ms
51,408 KB
testcase_12 AC 93 ms
52,136 KB
testcase_13 AC 108 ms
52,148 KB
testcase_14 AC 56 ms
50,148 KB
testcase_15 AC 55 ms
50,072 KB
testcase_16 AC 97 ms
52,376 KB
testcase_17 AC 111 ms
52,024 KB
testcase_18 AC 108 ms
51,880 KB
testcase_19 AC 112 ms
52,400 KB
testcase_20 AC 55 ms
49,960 KB
testcase_21 AC 55 ms
49,972 KB
testcase_22 AC 54 ms
50,076 KB
testcase_23 AC 56 ms
50,208 KB
testcase_24 AC 56 ms
50,388 KB
testcase_25 AC 57 ms
50,288 KB
testcase_26 AC 55 ms
50,100 KB
testcase_27 AC 57 ms
49,952 KB
testcase_28 AC 55 ms
50,332 KB
testcase_29 AC 87 ms
51,288 KB
testcase_30 AC 65 ms
50,576 KB
testcase_31 AC 55 ms
49,984 KB
testcase_32 AC 54 ms
50,292 KB
testcase_33 AC 55 ms
50,072 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