結果

問題 No.5 数字のブロック
ユーザー Ryugo AbeRyugo Abe
提出日時 2016-12-15 14:42:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 295 ms / 5,000 ms
コード長 790 bytes
コンパイル時間 3,203 ms
コンパイル使用メモリ 74,176 KB
実行使用メモリ 61,100 KB
最終ジャッジ日時 2023-08-11 16:58:36
合計ジャッジ時間 11,080 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,656 KB
testcase_01 AC 130 ms
56,152 KB
testcase_02 AC 129 ms
55,980 KB
testcase_03 AC 253 ms
59,780 KB
testcase_04 AC 235 ms
59,540 KB
testcase_05 AC 280 ms
60,548 KB
testcase_06 AC 244 ms
59,436 KB
testcase_07 AC 234 ms
59,736 KB
testcase_08 AC 241 ms
59,564 KB
testcase_09 AC 203 ms
58,896 KB
testcase_10 AC 270 ms
60,560 KB
testcase_11 AC 222 ms
59,580 KB
testcase_12 AC 251 ms
60,196 KB
testcase_13 AC 264 ms
59,940 KB
testcase_14 AC 143 ms
55,800 KB
testcase_15 AC 161 ms
55,928 KB
testcase_16 AC 273 ms
60,176 KB
testcase_17 AC 293 ms
61,100 KB
testcase_18 AC 283 ms
60,380 KB
testcase_19 AC 295 ms
60,640 KB
testcase_20 AC 131 ms
55,720 KB
testcase_21 AC 131 ms
55,856 KB
testcase_22 AC 131 ms
55,712 KB
testcase_23 AC 131 ms
55,548 KB
testcase_24 AC 159 ms
55,952 KB
testcase_25 AC 193 ms
55,744 KB
testcase_26 AC 132 ms
55,844 KB
testcase_27 AC 130 ms
55,764 KB
testcase_28 AC 132 ms
55,860 KB
testcase_29 AC 237 ms
59,968 KB
testcase_30 AC 215 ms
59,180 KB
testcase_31 AC 130 ms
55,800 KB
testcase_32 AC 131 ms
55,864 KB
testcase_33 AC 129 ms
55,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int boxWidth = sc.nextInt();
        int numBlock = sc.nextInt();

        List<Integer> blockWidthList = new ArrayList<Integer>();
        for (int i = 0; i < numBlock; i++) {
            blockWidthList.add(sc.nextInt());
        }

        Collections.sort(blockWidthList);
        int count = 0;
        int filledWidth = 0;
        for (Integer width : blockWidthList) {
            filledWidth += width;
            if (filledWidth > boxWidth) {
                break;
            }
            count++;
        }

        System.out.println(count);
    }
}
0