結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,168 KB
testcase_01 AC 131 ms
41,276 KB
testcase_02 AC 133 ms
41,304 KB
testcase_03 AC 120 ms
39,996 KB
testcase_04 AC 119 ms
40,164 KB
testcase_05 AC 130 ms
41,284 KB
testcase_06 AC 132 ms
41,296 KB
testcase_07 AC 130 ms
41,176 KB
testcase_08 AC 129 ms
41,280 KB
testcase_09 AC 127 ms
41,284 KB
testcase_10 AC 133 ms
41,380 KB
testcase_11 AC 127 ms
41,564 KB
testcase_12 AC 128 ms
41,192 KB
testcase_13 AC 129 ms
41,320 KB
testcase_14 AC 132 ms
41,240 KB
testcase_15 AC 133 ms
41,436 KB
testcase_16 AC 131 ms
41,168 KB
testcase_17 AC 129 ms
41,112 KB
testcase_18 AC 131 ms
41,280 KB
testcase_19 TLE -
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;
           }
           if(i==n-1){
               if(paid<=atari){
                   break;
               }
           }
           i++;
       }
       System.out.println(paid);
   }       
}
0