結果

問題 No.5 数字のブロック
ユーザー asf asfasf asf
提出日時 2020-05-14 07:04:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 264 ms / 5,000 ms
コード長 610 bytes
コンパイル時間 3,334 ms
コンパイル使用メモリ 71,964 KB
実行使用メモリ 60,780 KB
最終ジャッジ日時 2023-10-12 20:35:04
合計ジャッジ時間 11,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,992 KB
testcase_01 AC 127 ms
56,012 KB
testcase_02 AC 129 ms
55,896 KB
testcase_03 AC 239 ms
59,556 KB
testcase_04 AC 215 ms
59,024 KB
testcase_05 AC 246 ms
59,952 KB
testcase_06 AC 232 ms
60,184 KB
testcase_07 AC 218 ms
59,296 KB
testcase_08 AC 235 ms
59,520 KB
testcase_09 AC 201 ms
58,656 KB
testcase_10 AC 247 ms
60,172 KB
testcase_11 AC 221 ms
59,448 KB
testcase_12 AC 241 ms
60,076 KB
testcase_13 AC 248 ms
60,544 KB
testcase_14 AC 139 ms
55,832 KB
testcase_15 AC 152 ms
56,040 KB
testcase_16 AC 249 ms
60,024 KB
testcase_17 AC 256 ms
60,572 KB
testcase_18 AC 264 ms
59,768 KB
testcase_19 AC 263 ms
60,780 KB
testcase_20 AC 126 ms
55,796 KB
testcase_21 AC 125 ms
55,660 KB
testcase_22 AC 126 ms
55,448 KB
testcase_23 AC 128 ms
55,588 KB
testcase_24 AC 154 ms
55,776 KB
testcase_25 AC 180 ms
55,956 KB
testcase_26 AC 125 ms
55,780 KB
testcase_27 AC 124 ms
55,596 KB
testcase_28 AC 125 ms
55,824 KB
testcase_29 AC 210 ms
59,048 KB
testcase_30 AC 201 ms
58,388 KB
testcase_31 AC 123 ms
55,696 KB
testcase_32 AC 124 ms
55,996 KB
testcase_33 AC 124 ms
56,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b;
        a = sc.nextInt();
        b = sc.nextInt();
        int[] c = new int[b];
        for (int i = 0; i < b; i++) {
            c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        int sum = 0;
        int count = 0;
        for (int i = 0; i < b; i++) {
            if (sum + c[i] <= a) {
                sum += c[i];
                count++;
            }
        }
        System.out.println(count);
    }
}
0