結果

問題 No.78 クジ付きアイスバー
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-16 20:05:59
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 755 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 74,700 KB
実行使用メモリ 46,688 KB
最終ジャッジ日時 2024-04-16 05:00:45
合計ジャッジ時間 12,499 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
46,688 KB
testcase_01 AC 128 ms
41,316 KB
testcase_02 AC 128 ms
41,336 KB
testcase_03 AC 130 ms
41,108 KB
testcase_04 AC 131 ms
41,504 KB
testcase_05 AC 3,155 ms
41,172 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
   public static void main(String[] args) throws Exception {
       Scanner koko = new Scanner(System.in);
       int n = koko.nextInt();
       long k = koko.nextInt();
       String s = koko.next();
       int had=0;
       int paid=0;
       int atari=0;
       int i=0;
       while(had<k){
           paid++;
           if(atari>0){
               paid--;
               atari--;
           }
           if(s.charAt(i%n)=='0'){
               had++;
           }else if(s.charAt(i%n)=='1'){
               had++;
               atari++;
           }else if(s.charAt(i%n)=='2'){
               had++;
               atari+=2;
           }
           i++;
       }
       System.out.println(paid);
   }       
}
0