結果

問題 No.78 クジ付きアイスバー
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-16 20:40:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,322 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 77,472 KB
実行使用メモリ 41,904 KB
最終ジャッジ日時 2024-04-16 05:01:12
合計ジャッジ時間 8,301 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 114 ms
40,308 KB
testcase_02 AC 114 ms
40,188 KB
testcase_03 AC 127 ms
41,028 KB
testcase_04 AC 127 ms
41,216 KB
testcase_05 AC 115 ms
40,176 KB
testcase_06 AC 128 ms
41,340 KB
testcase_07 AC 118 ms
40,368 KB
testcase_08 AC 115 ms
40,012 KB
testcase_09 AC 130 ms
41,148 KB
testcase_10 AC 130 ms
41,168 KB
testcase_11 AC 118 ms
40,220 KB
testcase_12 AC 117 ms
40,372 KB
testcase_13 AC 130 ms
41,316 KB
testcase_14 AC 132 ms
41,140 KB
testcase_15 AC 131 ms
41,092 KB
testcase_16 AC 131 ms
41,396 KB
testcase_17 AC 129 ms
41,468 KB
testcase_18 AC 128 ms
41,248 KB
testcase_19 WA -
testcase_20 AC 130 ms
41,316 KB
testcase_21 AC 118 ms
39,864 KB
testcase_22 WA -
testcase_23 AC 115 ms
39,832 KB
testcase_24 AC 128 ms
41,024 KB
testcase_25 AC 127 ms
41,556 KB
testcase_26 AC 129 ms
41,272 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 132 ms
41,240 KB
testcase_30 AC 130 ms
41,328 KB
testcase_31 WA -
testcase_32 AC 117 ms
40,056 KB
testcase_33 WA -
testcase_34 AC 134 ms
41,028 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 130 ms
41,292 KB
testcase_38 AC 127 ms
41,212 KB
権限があれば一括ダウンロードができます

ソースコード

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 = new int[n];
       int atari=0;
       paid[0]=1;
       if(s.charAt(0)=='1'){
           atari=1;
       }else if(s.charAt(0)=='2'){
           atari=2;
       }
       for(int i=1; i<n; i++){
           paid[i]=paid[i-1]+1;
           if(atari>0){
               paid[i]--;
               atari--;
           }
           if(s.charAt(i)=='1'){
               atari++;
           }else if(s.charAt(i)=='2'){
               atari+=2;
           }
       }
       if(atari>=paid[n-1]){
           System.out.println(paid[n-1]);
       }else if(atari==0){
           int amari = (int)k%n;
           int ama=0;
           if(amari!=0){
               ama=paid[amari-1];
           }
           long rpay = (paid[n-1]*(k-amari)/n)+ama;
           System.out.println(rpay);
       }else{
           int amari=(int)k%n;
           int ama=0;
           if(amari!=0){
               ama=paid[amari-1]-atari;
           }
           long rpay = 1+(paid[n-1]-atari)*(k-amari)/n+ama;
           System.out.println(rpay);
       }
       
   }       
}
0