結果

問題 No.5 数字のブロック
ユーザー tentententen
提出日時 2020-11-10 09:47:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 268 ms / 5,000 ms
コード長 519 bytes
コンパイル時間 2,141 ms
コンパイル使用メモリ 71,476 KB
実行使用メモリ 62,008 KB
最終ジャッジ日時 2023-09-29 23:17:17
合計ジャッジ時間 11,134 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,824 KB
testcase_01 AC 125 ms
56,016 KB
testcase_02 AC 123 ms
56,024 KB
testcase_03 AC 229 ms
59,288 KB
testcase_04 AC 209 ms
58,872 KB
testcase_05 AC 244 ms
59,992 KB
testcase_06 AC 214 ms
59,588 KB
testcase_07 AC 227 ms
59,164 KB
testcase_08 AC 220 ms
60,360 KB
testcase_09 AC 194 ms
58,716 KB
testcase_10 AC 242 ms
62,008 KB
testcase_11 AC 217 ms
59,308 KB
testcase_12 AC 235 ms
59,816 KB
testcase_13 AC 241 ms
59,664 KB
testcase_14 AC 138 ms
55,752 KB
testcase_15 AC 152 ms
55,744 KB
testcase_16 AC 241 ms
59,728 KB
testcase_17 AC 259 ms
61,072 KB
testcase_18 AC 256 ms
59,736 KB
testcase_19 AC 268 ms
61,212 KB
testcase_20 AC 126 ms
55,752 KB
testcase_21 AC 125 ms
55,688 KB
testcase_22 AC 126 ms
55,768 KB
testcase_23 AC 128 ms
55,524 KB
testcase_24 AC 154 ms
55,964 KB
testcase_25 AC 180 ms
56,220 KB
testcase_26 AC 124 ms
55,688 KB
testcase_27 AC 124 ms
55,704 KB
testcase_28 AC 124 ms
55,708 KB
testcase_29 AC 208 ms
59,004 KB
testcase_30 AC 200 ms
58,668 KB
testcase_31 AC 123 ms
55,848 KB
testcase_32 AC 123 ms
55,780 KB
testcase_33 AC 125 ms
55,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        while (count < n && arr[count] <= length) {
            length -= arr[count];
            count++;
        }
        System.out.println(count);
    }
}
0