結果

問題 No.5 数字のブロック
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-23 11:09:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 911 bytes
コンパイル時間 2,246 ms
コンパイル使用メモリ 75,380 KB
実行使用メモリ 40,248 KB
最終ジャッジ日時 2024-04-29 08:55:35
合計ジャッジ時間 5,621 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
37,112 KB
testcase_01 AC 53 ms
36,932 KB
testcase_02 AC 56 ms
37,096 KB
testcase_03 AC 86 ms
38,756 KB
testcase_04 AC 76 ms
38,468 KB
testcase_05 AC 100 ms
39,368 KB
testcase_06 AC 91 ms
38,736 KB
testcase_07 AC 76 ms
38,508 KB
testcase_08 AC 92 ms
38,584 KB
testcase_09 AC 64 ms
37,656 KB
testcase_10 AC 98 ms
39,208 KB
testcase_11 AC 86 ms
38,528 KB
testcase_12 AC 88 ms
39,736 KB
testcase_13 AC 92 ms
40,112 KB
testcase_14 AC 54 ms
36,932 KB
testcase_15 AC 54 ms
37,144 KB
testcase_16 AC 91 ms
39,760 KB
testcase_17 AC 107 ms
40,108 KB
testcase_18 AC 94 ms
40,248 KB
testcase_19 AC 108 ms
40,160 KB
testcase_20 AC 54 ms
37,040 KB
testcase_21 AC 53 ms
37,132 KB
testcase_22 AC 56 ms
37,020 KB
testcase_23 AC 55 ms
36,652 KB
testcase_24 AC 54 ms
36,792 KB
testcase_25 AC 56 ms
37,036 KB
testcase_26 AC 53 ms
36,792 KB
testcase_27 AC 54 ms
37,144 KB
testcase_28 AC 54 ms
37,176 KB
testcase_29 AC 78 ms
38,544 KB
testcase_30 AC 64 ms
37,632 KB
testcase_31 AC 53 ms
37,112 KB
testcase_32 AC 53 ms
37,112 KB
testcase_33 AC 55 ms
36,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int L = Integer.parseInt(reader.readLine());
        int N = Integer.parseInt(reader.readLine());
        String[] line = reader.readLine().split(" ");
        int[] blocks = new int[N + 1];
        for (int i = 0; i < N; i++) {
            blocks[i + 1] = Integer.parseInt(line[i]);
        }
        Arrays.sort(blocks);

        int counter = 0;
        for (int i = 1; i <= N; i++) {
            blocks[i] = blocks[i - 1] + blocks[i];
            if (blocks[i] > L) {
                break;
            } else {
                counter += 1;
            }
        }
        System.out.println(counter);
    }
}
0