結果

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

ソースコード

diff #

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

    ans = 0

    x1 = 0
    y1 = 0

    b1, b2 = divmod(K, N)

    if b1 > 0:
        for i in range(N):
            if y1 == 0:
                x1 += 1
            else:
                y1 -= 1
            y1 += S[i]
        x2 = max(x1 - y1, 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