結果

問題 No.5 数字のブロック
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-01-10 11:30:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 247 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 2,208 ms
コンパイル使用メモリ 76,900 KB
実行使用メモリ 47,940 KB
最終ジャッジ日時 2024-04-29 06:46:48
合計ジャッジ時間 8,420 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
41,024 KB
testcase_01 AC 100 ms
40,848 KB
testcase_02 AC 103 ms
41,132 KB
testcase_03 AC 209 ms
47,248 KB
testcase_04 AC 203 ms
45,932 KB
testcase_05 AC 234 ms
46,968 KB
testcase_06 AC 217 ms
45,836 KB
testcase_07 AC 205 ms
45,616 KB
testcase_08 AC 208 ms
46,408 KB
testcase_09 AC 181 ms
43,564 KB
testcase_10 AC 247 ms
47,228 KB
testcase_11 AC 199 ms
46,168 KB
testcase_12 AC 214 ms
46,640 KB
testcase_13 AC 222 ms
46,492 KB
testcase_14 AC 121 ms
41,368 KB
testcase_15 AC 127 ms
41,744 KB
testcase_16 AC 230 ms
47,404 KB
testcase_17 AC 243 ms
47,940 KB
testcase_18 AC 233 ms
47,584 KB
testcase_19 AC 246 ms
47,848 KB
testcase_20 AC 98 ms
41,376 KB
testcase_21 AC 102 ms
40,912 KB
testcase_22 AC 106 ms
39,936 KB
testcase_23 AC 113 ms
40,956 KB
testcase_24 AC 144 ms
41,400 KB
testcase_25 AC 153 ms
41,624 KB
testcase_26 AC 109 ms
41,092 KB
testcase_27 AC 98 ms
41,584 KB
testcase_28 AC 110 ms
41,292 KB
testcase_29 AC 202 ms
45,828 KB
testcase_30 AC 176 ms
43,960 KB
testcase_31 AC 108 ms
41,172 KB
testcase_32 AC 101 ms
40,956 KB
testcase_33 AC 107 ms
41,336 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