結果

問題 No.156 キャンディー・ボックス
ユーザー mobius_bkstmobius_bkst
提出日時 2015-04-20 20:42:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,016 bytes
コンパイル時間 3,466 ms
コンパイル使用メモリ 73,128 KB
実行使用メモリ 52,408 KB
最終ジャッジ日時 2023-09-18 01:45:08
合計ジャッジ時間 7,019 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 44 ms
49,556 KB
testcase_03 AC 45 ms
49,560 KB
testcase_04 AC 46 ms
49,276 KB
testcase_05 AC 45 ms
49,248 KB
testcase_06 AC 45 ms
49,104 KB
testcase_07 AC 46 ms
49,188 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 44 ms
49,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 46 ms
49,304 KB
testcase_15 AC 45 ms
49,388 KB
testcase_16 AC 44 ms
49,096 KB
testcase_17 AC 44 ms
49,068 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 47 ms
49,440 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 45 ms
49,428 KB
testcase_27 AC 44 ms
49,428 KB
testcase_28 AC 44 ms
49,372 KB
testcase_29 AC 45 ms
49,592 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 44 ms
49,924 KB
testcase_33 AC 45 ms
49,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class No156 {


    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    System.in));
            String[] nm = br.readLine().split(" ");
            int N = Integer.parseInt(nm[0]);
            int M = Integer.parseInt(nm[1]);

            String[] CStr = br.readLine().split(" ");
            int[] C = new int[N];
            for (int i = 0; i < N; i++) {
                C[i] = Integer.parseInt(CStr[1]);
            }

            int emptyCount = 0;
            for (int i = 0; i < C.length; i++) {

                if (C[i] <= M) {
                    M = M - C[i];
                    emptyCount++;
                } else {
                    break;
                }

            }

            System.out.println(emptyCount);
        } catch (Exception e) {
            System.err.println("Error:" + e.getMessage());
        }
    }

}
0