結果

問題 No.156 キャンディー・ボックス
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-29 20:25:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,043 bytes
コンパイル時間 4,286 ms
コンパイル使用メモリ 85,416 KB
実行使用メモリ 52,672 KB
最終ジャッジ日時 2023-09-19 03:21:48
合計ジャッジ時間 7,799 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
50,612 KB
testcase_01 AC 60 ms
50,596 KB
testcase_02 AC 60 ms
50,964 KB
testcase_03 AC 59 ms
50,596 KB
testcase_04 AC 61 ms
50,672 KB
testcase_05 AC 67 ms
51,324 KB
testcase_06 AC 69 ms
51,220 KB
testcase_07 AC 68 ms
51,104 KB
testcase_08 AC 71 ms
52,428 KB
testcase_09 AC 68 ms
51,364 KB
testcase_10 AC 67 ms
52,188 KB
testcase_11 AC 67 ms
52,312 KB
testcase_12 AC 67 ms
51,336 KB
testcase_13 AC 71 ms
51,324 KB
testcase_14 AC 67 ms
52,624 KB
testcase_15 AC 67 ms
51,200 KB
testcase_16 AC 67 ms
51,392 KB
testcase_17 AC 68 ms
51,340 KB
testcase_18 AC 69 ms
52,672 KB
testcase_19 AC 68 ms
52,660 KB
testcase_20 AC 61 ms
50,556 KB
testcase_21 AC 61 ms
50,548 KB
testcase_22 AC 67 ms
51,256 KB
testcase_23 AC 62 ms
51,108 KB
testcase_24 AC 60 ms
50,672 KB
testcase_25 AC 61 ms
50,544 KB
testcase_26 AC 60 ms
50,644 KB
testcase_27 AC 60 ms
50,708 KB
testcase_28 AC 60 ms
50,556 KB
testcase_29 AC 59 ms
50,812 KB
testcase_30 AC 68 ms
52,308 KB
testcase_31 AC 69 ms
51,204 KB
testcase_32 AC 87 ms
51,416 KB
testcase_33 AC 87 ms
51,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        int N = Integer.parseInt(inputs[0]);
        int M = Integer.parseInt(inputs[1]);
        inputs = reader.readLine().split(" ");
        int[] boxes = Stream.of(inputs).mapToInt(Integer::parseInt).toArray();
        Arrays.sort(boxes);
        int index = 0;
        while (M != 0) {
            if (boxes[index] == 0) {
                index += 1;
            } else {
                boxes[index] -= 1;
                M -= 1;
            }
        }
        if (boxes[index] == 0) {
            System.out.println(index + 1);
        } else {
            System.out.println(index);
        }

    }
}
0