結果

問題 No.78 クジ付きアイスバー
コンテスト
ユーザー tnodino
提出日時 2022-06-11 02:25:00
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 22 ms / 5,000 ms
+ 665µs
コード長 448 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 62 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-10 15:41:45
合計ジャッジ時間 3,205 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def check(K):
    ret = 0
    cnt = 0
    for i in range(K):
        if cnt == 0:
            ret += 1
        else:
            cnt -= 1
        cnt += S[i]
    return cnt, ret

N,K = map(int,input().split())
S = list(map(int,input()))
if K <= N:
    _,ans = check(K)
    print(ans)
else:
    cnt,buy = check(N)
    if buy <= cnt:
        print(buy)
    else:
        _,ans = check(K%N)
        print(buy + (buy-cnt) * (K//N-1) + max(0, ans-cnt))
0