結果

問題 No.5 数字のブロック
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-23 11:07:07
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 910 bytes
コンパイル時間 4,958 ms
コンパイル使用メモリ 72,004 KB
実行使用メモリ 52,964 KB
最終ジャッジ日時 2023-09-29 01:23:12
合計ジャッジ時間 8,118 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,424 KB
testcase_01 AC 45 ms
49,360 KB
testcase_02 WA -
testcase_03 AC 90 ms
52,792 KB
testcase_04 AC 68 ms
51,732 KB
testcase_05 AC 94 ms
52,584 KB
testcase_06 AC 75 ms
51,676 KB
testcase_07 AC 70 ms
51,608 KB
testcase_08 AC 81 ms
51,676 KB
testcase_09 AC 58 ms
50,276 KB
testcase_10 AC 83 ms
52,940 KB
testcase_11 AC 69 ms
51,340 KB
testcase_12 AC 91 ms
52,716 KB
testcase_13 AC 87 ms
52,964 KB
testcase_14 AC 46 ms
49,788 KB
testcase_15 AC 48 ms
49,356 KB
testcase_16 AC 91 ms
52,508 KB
testcase_17 AC 99 ms
51,372 KB
testcase_18 AC 81 ms
52,876 KB
testcase_19 AC 98 ms
52,896 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 46 ms
49,440 KB
testcase_24 AC 48 ms
49,384 KB
testcase_25 AC 51 ms
49,368 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 65 ms
51,708 KB
testcase_30 AC 57 ms
50,796 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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