結果

問題 No.5 数字のブロック
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-23 11:09:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 95 ms / 5,000 ms
コード長 911 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 72,900 KB
実行使用メモリ 53,092 KB
最終ジャッジ日時 2023-08-11 17:16:08
合計ジャッジ時間 5,565 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,480 KB
testcase_01 AC 44 ms
49,788 KB
testcase_02 AC 44 ms
49,640 KB
testcase_03 AC 80 ms
52,948 KB
testcase_04 AC 66 ms
51,088 KB
testcase_05 AC 93 ms
52,856 KB
testcase_06 AC 76 ms
52,476 KB
testcase_07 AC 78 ms
50,644 KB
testcase_08 AC 74 ms
51,424 KB
testcase_09 AC 58 ms
50,868 KB
testcase_10 AC 83 ms
52,812 KB
testcase_11 AC 65 ms
51,544 KB
testcase_12 AC 89 ms
52,652 KB
testcase_13 AC 92 ms
52,732 KB
testcase_14 AC 45 ms
49,380 KB
testcase_15 AC 47 ms
49,284 KB
testcase_16 AC 80 ms
52,180 KB
testcase_17 AC 95 ms
53,088 KB
testcase_18 AC 92 ms
52,972 KB
testcase_19 AC 93 ms
53,092 KB
testcase_20 AC 44 ms
49,276 KB
testcase_21 AC 44 ms
49,464 KB
testcase_22 AC 45 ms
49,572 KB
testcase_23 AC 45 ms
49,372 KB
testcase_24 AC 48 ms
49,492 KB
testcase_25 AC 50 ms
49,416 KB
testcase_26 AC 45 ms
49,588 KB
testcase_27 AC 44 ms
49,356 KB
testcase_28 AC 44 ms
49,536 KB
testcase_29 AC 64 ms
51,956 KB
testcase_30 AC 58 ms
50,460 KB
testcase_31 AC 45 ms
49,776 KB
testcase_32 AC 43 ms
49,608 KB
testcase_33 AC 45 ms
49,440 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