結果

問題 No.5 数字のブロック
ユーザー tk55513tk55513
提出日時 2020-09-05 21:55:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 258 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 1,929 ms
コンパイル使用メモリ 72,332 KB
実行使用メモリ 60,760 KB
最終ジャッジ日時 2023-08-19 13:06:56
合計ジャッジ時間 9,557 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,064 KB
testcase_01 AC 123 ms
56,152 KB
testcase_02 AC 119 ms
56,012 KB
testcase_03 AC 216 ms
59,304 KB
testcase_04 AC 215 ms
59,292 KB
testcase_05 AC 254 ms
60,120 KB
testcase_06 AC 218 ms
59,428 KB
testcase_07 AC 218 ms
59,600 KB
testcase_08 AC 230 ms
59,820 KB
testcase_09 AC 198 ms
58,848 KB
testcase_10 AC 247 ms
60,484 KB
testcase_11 AC 217 ms
59,752 KB
testcase_12 AC 237 ms
60,020 KB
testcase_13 AC 251 ms
60,564 KB
testcase_14 AC 138 ms
56,020 KB
testcase_15 AC 143 ms
55,648 KB
testcase_16 AC 243 ms
59,716 KB
testcase_17 AC 255 ms
60,112 KB
testcase_18 AC 253 ms
60,656 KB
testcase_19 AC 258 ms
60,760 KB
testcase_20 AC 124 ms
56,036 KB
testcase_21 AC 124 ms
55,632 KB
testcase_22 AC 122 ms
55,928 KB
testcase_23 AC 123 ms
55,564 KB
testcase_24 AC 151 ms
55,808 KB
testcase_25 AC 179 ms
55,808 KB
testcase_26 AC 123 ms
56,216 KB
testcase_27 AC 125 ms
55,984 KB
testcase_28 AC 124 ms
56,172 KB
testcase_29 AC 206 ms
59,404 KB
testcase_30 AC 201 ms
58,596 KB
testcase_31 AC 124 ms
55,936 KB
testcase_32 AC 123 ms
55,968 KB
testcase_33 AC 124 ms
55,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }
        Arrays.sort(w);
        for (int i = 0; i < w.length; i++) {
            if (l - w[i] < 0) {
                System.out.println(i);
                return;
            }
            l -= w[i];
        }
        System.out.println(n);

    }
}
0