結果

問題 No.156 キャンディー・ボックス
ユーザー matsuyoshi30matsuyoshi30
提出日時 2017-01-25 23:59:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 72,216 KB
実行使用メモリ 58,284 KB
最終ジャッジ日時 2023-08-24 23:13:03
合計ジャッジ時間 8,035 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 119 ms
55,900 KB
testcase_03 AC 122 ms
55,848 KB
testcase_04 AC 121 ms
55,920 KB
testcase_05 WA -
testcase_06 AC 123 ms
55,564 KB
testcase_07 AC 124 ms
54,132 KB
testcase_08 AC 121 ms
55,880 KB
testcase_09 AC 121 ms
56,248 KB
testcase_10 AC 120 ms
55,984 KB
testcase_11 AC 122 ms
56,152 KB
testcase_12 AC 121 ms
55,728 KB
testcase_13 AC 122 ms
55,536 KB
testcase_14 AC 122 ms
56,004 KB
testcase_15 AC 123 ms
56,112 KB
testcase_16 AC 121 ms
56,200 KB
testcase_17 AC 121 ms
56,008 KB
testcase_18 WA -
testcase_19 AC 121 ms
55,784 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 121 ms
55,916 KB
testcase_24 AC 122 ms
56,144 KB
testcase_25 AC 120 ms
56,056 KB
testcase_26 AC 121 ms
56,028 KB
testcase_27 AC 120 ms
55,736 KB
testcase_28 WA -
testcase_29 AC 120 ms
55,640 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 122 ms
55,720 KB
testcase_33 AC 124 ms
55,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] c = new int[n];
        for(int i=0; i<n; i++) {
            c[i] = in.nextInt();
        }

        int cnt = 0;

        for(int i=0; i<n; i++) {
            int taken = Math.min(m, c[i]);

            c[i] -= taken;
            m -= taken;

            if(c[i] == 0) {
                cnt++;
            }
        }

        System.out.println(cnt);

        in.close();
    }
}
0