結果

問題 No.5 数字のブロック
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-01-10 11:30:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 261 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 3,027 ms
コンパイル使用メモリ 73,208 KB
実行使用メモリ 60,812 KB
最終ジャッジ日時 2023-08-11 14:31:00
合計ジャッジ時間 9,485 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,720 KB
testcase_01 AC 124 ms
56,276 KB
testcase_02 AC 114 ms
55,452 KB
testcase_03 AC 226 ms
59,728 KB
testcase_04 AC 212 ms
59,324 KB
testcase_05 AC 256 ms
60,476 KB
testcase_06 AC 228 ms
59,980 KB
testcase_07 AC 215 ms
57,660 KB
testcase_08 AC 230 ms
59,192 KB
testcase_09 AC 194 ms
58,584 KB
testcase_10 AC 255 ms
60,488 KB
testcase_11 AC 215 ms
59,320 KB
testcase_12 AC 230 ms
59,888 KB
testcase_13 AC 238 ms
60,276 KB
testcase_14 AC 137 ms
55,952 KB
testcase_15 AC 142 ms
55,844 KB
testcase_16 AC 243 ms
60,416 KB
testcase_17 AC 258 ms
60,812 KB
testcase_18 AC 258 ms
58,536 KB
testcase_19 AC 261 ms
60,432 KB
testcase_20 AC 118 ms
55,724 KB
testcase_21 AC 118 ms
56,076 KB
testcase_22 AC 117 ms
56,432 KB
testcase_23 AC 119 ms
55,952 KB
testcase_24 AC 142 ms
56,040 KB
testcase_25 AC 170 ms
55,656 KB
testcase_26 AC 116 ms
55,708 KB
testcase_27 AC 117 ms
55,812 KB
testcase_28 AC 118 ms
55,800 KB
testcase_29 AC 216 ms
58,948 KB
testcase_30 AC 193 ms
58,832 KB
testcase_31 AC 114 ms
55,652 KB
testcase_32 AC 118 ms
55,920 KB
testcase_33 AC 117 ms
55,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        ArrayList<Integer> W = new ArrayList<>();

        int L = in.nextInt();
        int N = in.nextInt();
        for(int i = 0; i < N; i++) {
            W.add(in.nextInt());
        }
        Collections.sort(W);
        int i = 0;
        while(L >= 0 && i < N) {
            L = L - W.get(i);
            if(L >= 0) {
                i++;
            } else {
                break;
            }
        }

        System.out.println(i);
    }
}
0