結果

問題 No.78 クジ付きアイスバー
ユーザー GrenacheGrenache
提出日時 2015-11-06 20:07:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 938 bytes
コンパイル時間 3,857 ms
コンパイル使用メモリ 77,608 KB
実行使用メモリ 54,592 KB
最終ジャッジ日時 2024-04-16 05:44:55
合計ジャッジ時間 10,984 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
54,120 KB
testcase_01 AC 139 ms
53,968 KB
testcase_02 AC 142 ms
53,864 KB
testcase_03 AC 146 ms
53,836 KB
testcase_04 AC 144 ms
54,244 KB
testcase_05 AC 142 ms
54,068 KB
testcase_06 AC 141 ms
54,324 KB
testcase_07 AC 142 ms
53,884 KB
testcase_08 AC 142 ms
54,220 KB
testcase_09 AC 144 ms
54,068 KB
testcase_10 AC 144 ms
54,048 KB
testcase_11 AC 145 ms
53,888 KB
testcase_12 AC 140 ms
53,988 KB
testcase_13 AC 142 ms
54,140 KB
testcase_14 AC 140 ms
53,904 KB
testcase_15 AC 142 ms
54,132 KB
testcase_16 AC 144 ms
54,284 KB
testcase_17 AC 145 ms
53,796 KB
testcase_18 AC 142 ms
53,928 KB
testcase_19 WA -
testcase_20 AC 140 ms
54,108 KB
testcase_21 AC 142 ms
53,972 KB
testcase_22 WA -
testcase_23 AC 142 ms
54,196 KB
testcase_24 AC 148 ms
54,392 KB
testcase_25 AC 144 ms
54,268 KB
testcase_26 AC 139 ms
54,088 KB
testcase_27 AC 139 ms
54,592 KB
testcase_28 AC 143 ms
54,156 KB
testcase_29 AC 141 ms
54,084 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 146 ms
53,956 KB
testcase_33 AC 146 ms
54,240 KB
testcase_34 WA -
testcase_35 AC 142 ms
53,872 KB
testcase_36 AC 141 ms
53,976 KB
testcase_37 AC 140 ms
53,900 KB
testcase_38 AC 141 ms
54,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder78 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] a = new int[n + 1];
        int[] min = new int[n + 1];

        for (int i = 1; i <= n; i++) {
        	if (a[i - 1] > 0) {
        		min[i] = min[i - 1];
        		a[i] = a[i - 1] - 1 + s[i - 1] - '0';
        	} else {
        		min[i] = min[i - 1] + 1;
        		a[i] = a[i - 1] + s[i - 1] - '0';
        	}
        }
        
        if (k > n && a[n] >= min[n]) {
        	System.out.println(min[n]);
        } else if (k <= n) {
        	System.out.println(min[k]);
        } else {
        	long ret = (min[n] - a[n]) * (k / n - 1);
        	ret += min[n] + min[k % n] - a[n];
        	
        	System.out.println(ret);
        }

        sc.close();
    }
}
0