結果

問題 No.5 数字のブロック
ユーザー asf asfasf asf
提出日時 2020-05-14 07:03:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 3,608 ms
コンパイル使用メモリ 71,976 KB
実行使用メモリ 61,256 KB
最終ジャッジ日時 2023-10-12 20:33:55
合計ジャッジ時間 11,808 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,808 KB
testcase_01 AC 129 ms
55,812 KB
testcase_02 WA -
testcase_03 AC 239 ms
60,140 KB
testcase_04 AC 220 ms
57,540 KB
testcase_05 WA -
testcase_06 AC 227 ms
58,804 KB
testcase_07 AC 218 ms
59,224 KB
testcase_08 AC 226 ms
59,360 KB
testcase_09 AC 202 ms
58,860 KB
testcase_10 AC 257 ms
60,636 KB
testcase_11 AC 221 ms
59,776 KB
testcase_12 AC 239 ms
60,316 KB
testcase_13 AC 247 ms
60,624 KB
testcase_14 AC 139 ms
55,832 KB
testcase_15 WA -
testcase_16 AC 250 ms
60,248 KB
testcase_17 AC 264 ms
60,764 KB
testcase_18 AC 262 ms
60,504 KB
testcase_19 AC 269 ms
60,480 KB
testcase_20 AC 131 ms
55,824 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 127 ms
55,652 KB
testcase_24 AC 155 ms
56,028 KB
testcase_25 AC 188 ms
56,260 KB
testcase_26 AC 128 ms
55,884 KB
testcase_27 AC 128 ms
55,872 KB
testcase_28 AC 128 ms
55,660 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 129 ms
55,884 KB
testcase_32 AC 128 ms
55,904 KB
testcase_33 AC 128 ms
55,516 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