結果

問題 No.78 クジ付きアイスバー
ユーザー jp_stejp_ste
提出日時 2016-05-11 17:16:05
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 914 bytes
コンパイル時間 2,505 ms
コンパイル使用メモリ 79,732 KB
実行使用メモリ 41,504 KB
最終ジャッジ日時 2024-04-16 06:14:41
合計ジャッジ時間 54,362 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
40,964 KB
testcase_01 AC 132 ms
41,108 KB
testcase_02 AC 135 ms
41,016 KB
testcase_03 AC 136 ms
41,124 KB
testcase_04 AC 135 ms
41,472 KB
testcase_05 AC 658 ms
41,080 KB
testcase_06 AC 1,655 ms
41,388 KB
testcase_07 AC 719 ms
41,068 KB
testcase_08 AC 817 ms
41,128 KB
testcase_09 AC 2,548 ms
41,412 KB
testcase_10 AC 1,450 ms
40,920 KB
testcase_11 AC 764 ms
41,228 KB
testcase_12 AC 2,939 ms
41,216 KB
testcase_13 AC 2,434 ms
41,136 KB
testcase_14 AC 2,551 ms
41,292 KB
testcase_15 AC 1,272 ms
40,864 KB
testcase_16 AC 1,904 ms
41,376 KB
testcase_17 AC 2,226 ms
41,456 KB
testcase_18 AC 2,053 ms
41,344 KB
testcase_19 AC 2,562 ms
41,372 KB
testcase_20 AC 2,941 ms
41,152 KB
testcase_21 AC 3,242 ms
41,204 KB
testcase_22 AC 2,898 ms
41,068 KB
testcase_23 AC 134 ms
41,292 KB
testcase_24 AC 134 ms
41,108 KB
testcase_25 AC 134 ms
41,436 KB
testcase_26 AC 134 ms
41,148 KB
testcase_27 AC 132 ms
41,212 KB
testcase_28 AC 133 ms
41,112 KB
testcase_29 AC 150 ms
41,196 KB
testcase_30 AC 137 ms
41,236 KB
testcase_31 AC 134 ms
41,056 KB
testcase_32 AC 134 ms
41,236 KB
testcase_33 AC 150 ms
41,504 KB
testcase_34 AC 791 ms
41,244 KB
testcase_35 AC 1,520 ms
40,936 KB
testcase_36 AC 2,497 ms
41,164 KB
testcase_37 TLE -
testcase_38 AC 2,784 ms
41,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int n = Integer.parseInt(scan.next());
            int k = Integer.parseInt(scan.next());
            String s = scan.next();
            
            int buy = 0;
            int stack = 0;
            int sum = 0;
            int index = 0;
            
            while(true) {
                
                if(stack == 0) {
                    buy++;
                    sum++;
                } else {
                    stack--;
                }
                
                int now = s.charAt(index) - '0';
                stack += now;
                sum += now;
                if(++index == s.length()) index = 0;
                
                if(sum >= k) break;
            }
            System.out.println(buy);
        }
    }
}
0