結果

問題 No.78 クジ付きアイスバー
ユーザー しらっ亭しらっ亭
提出日時 2015-08-22 10:27:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-06 18:19:15
合計ジャッジ時間 2,394 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N, K = list(map(int, input().split()))
    S = list(map(int, input()))

    x1 = 0
    y1 = 0
    for i in range(N):
        if y1 == 0:
            x1 += 1
        else:
            y1 -= 1
        y1 += S[i]

    x2 = max(x1 - y1, 0)

    b1, b2 = divmod(K, N)
    ans = 0

    if b1 > 0:
        ans += x1
        b1 -= 1
    ans += b1 * x2

    x3 = 0
    y3 = y1
    for i in range(b2):
        if y3 == 0:
            x3 += 1
        else:
            y3 -= 1
        y3 += S[i]

    ans += x3

    print(ans)


if __name__ == '__main__':
    solve()
0