結果

問題 No.5 数字のブロック
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-26 22:13:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 279 ms / 5,000 ms
コード長 628 bytes
コンパイル時間 3,646 ms
コンパイル使用メモリ 75,132 KB
実行使用メモリ 47,664 KB
最終ジャッジ日時 2024-04-29 09:27:37
合計ジャッジ時間 11,183 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
40,624 KB
testcase_01 AC 118 ms
40,144 KB
testcase_02 AC 127 ms
41,032 KB
testcase_03 AC 243 ms
46,588 KB
testcase_04 AC 219 ms
45,732 KB
testcase_05 AC 251 ms
46,380 KB
testcase_06 AC 239 ms
46,376 KB
testcase_07 AC 232 ms
45,488 KB
testcase_08 AC 236 ms
45,752 KB
testcase_09 AC 204 ms
43,512 KB
testcase_10 AC 261 ms
46,972 KB
testcase_11 AC 227 ms
45,992 KB
testcase_12 AC 246 ms
46,420 KB
testcase_13 AC 255 ms
46,672 KB
testcase_14 AC 144 ms
41,588 KB
testcase_15 AC 154 ms
41,048 KB
testcase_16 AC 247 ms
46,572 KB
testcase_17 AC 269 ms
47,084 KB
testcase_18 AC 267 ms
47,388 KB
testcase_19 AC 279 ms
47,664 KB
testcase_20 AC 129 ms
41,536 KB
testcase_21 AC 126 ms
41,096 KB
testcase_22 AC 128 ms
41,332 KB
testcase_23 AC 116 ms
40,068 KB
testcase_24 AC 162 ms
41,384 KB
testcase_25 AC 175 ms
41,864 KB
testcase_26 AC 127 ms
41,236 KB
testcase_27 AC 118 ms
39,932 KB
testcase_28 AC 128 ms
41,032 KB
testcase_29 AC 223 ms
45,584 KB
testcase_30 AC 206 ms
43,708 KB
testcase_31 AC 128 ms
41,432 KB
testcase_32 AC 115 ms
40,292 KB
testcase_33 AC 116 ms
40,096 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