結果

問題 No.5 数字のブロック
ユーザー トミートミー
提出日時 2024-03-31 19:21:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 527 bytes
コンパイル時間 2,876 ms
コンパイル使用メモリ 73,948 KB
実行使用メモリ 62,344 KB
最終ジャッジ日時 2024-03-31 19:21:28
合計ジャッジ時間 10,914 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
57,832 KB
testcase_01 AC 129 ms
57,804 KB
testcase_02 WA -
testcase_03 AC 235 ms
61,944 KB
testcase_04 AC 219 ms
61,164 KB
testcase_05 AC 243 ms
62,044 KB
testcase_06 AC 233 ms
61,508 KB
testcase_07 AC 217 ms
61,160 KB
testcase_08 AC 233 ms
61,564 KB
testcase_09 AC 196 ms
60,324 KB
testcase_10 AC 245 ms
61,760 KB
testcase_11 AC 222 ms
61,476 KB
testcase_12 AC 238 ms
60,700 KB
testcase_13 AC 243 ms
61,984 KB
testcase_14 AC 133 ms
57,704 KB
testcase_15 AC 142 ms
57,960 KB
testcase_16 AC 254 ms
62,016 KB
testcase_17 AC 264 ms
62,344 KB
testcase_18 AC 257 ms
62,028 KB
testcase_19 AC 257 ms
62,280 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 131 ms
57,952 KB
testcase_24 AC 144 ms
57,960 KB
testcase_25 AC 175 ms
57,948 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 222 ms
61,140 KB
testcase_30 AC 211 ms
58,688 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        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();
        }

        sc.close();
        Arrays.sort(w);
        int cnt = 0;
        int sum = 0;
        for (cnt = 0; cnt != n && sum <= l; cnt++) {
            sum += w[cnt];
        }
        System.out.println(cnt - 1);

    }
}
0