結果

問題 No.5 数字のブロック
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-26 22:13:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 260 ms / 5,000 ms
コード長 628 bytes
コンパイル時間 5,162 ms
コンパイル使用メモリ 72,304 KB
実行使用メモリ 61,396 KB
最終ジャッジ日時 2023-08-11 17:53:42
合計ジャッジ時間 12,822 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,436 KB
testcase_01 AC 127 ms
55,588 KB
testcase_02 AC 128 ms
55,700 KB
testcase_03 AC 246 ms
59,640 KB
testcase_04 AC 222 ms
59,172 KB
testcase_05 AC 257 ms
60,524 KB
testcase_06 AC 226 ms
59,420 KB
testcase_07 AC 225 ms
59,832 KB
testcase_08 AC 234 ms
61,396 KB
testcase_09 AC 199 ms
59,144 KB
testcase_10 AC 256 ms
60,052 KB
testcase_11 AC 216 ms
59,408 KB
testcase_12 AC 235 ms
60,304 KB
testcase_13 AC 243 ms
61,068 KB
testcase_14 AC 138 ms
55,712 KB
testcase_15 AC 151 ms
55,956 KB
testcase_16 AC 244 ms
59,556 KB
testcase_17 AC 256 ms
60,360 KB
testcase_18 AC 258 ms
60,204 KB
testcase_19 AC 260 ms
60,788 KB
testcase_20 AC 125 ms
55,704 KB
testcase_21 AC 127 ms
55,744 KB
testcase_22 AC 126 ms
55,932 KB
testcase_23 AC 126 ms
55,848 KB
testcase_24 AC 153 ms
55,812 KB
testcase_25 AC 183 ms
56,036 KB
testcase_26 AC 126 ms
55,704 KB
testcase_27 AC 124 ms
55,700 KB
testcase_28 AC 125 ms
55,712 KB
testcase_29 AC 218 ms
59,756 KB
testcase_30 AC 193 ms
58,848 KB
testcase_31 AC 128 ms
55,448 KB
testcase_32 AC 128 ms
55,864 KB
testcase_33 AC 128 ms
55,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No5 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int length = s.nextInt();
        int count = s.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < count; i++) {
            sum += arr[i];
            if (sum > length) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(count);
    }
}
0