結果

問題 No.78 クジ付きアイスバー
ユーザー 👑 rin204
提出日時 2022-07-05 16:55:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 498 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2024-12-16 00:01:33
合計ジャッジ時間 3,333 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
S = list(map(int, input()))
cnt = 0
tot = 0
for i, s in enumerate(S, 1):
    if tot == 0:
        cnt += 1
        tot += 1
    tot -= 1
    tot += s
    if i == k:
        print(cnt)
        exit()
    
if sum(S) > n:
    print(cnt)
    exit()
c = (k - 1) // n - 1
cnt += c * (n - sum(S))
k = (k - 1) % n + 1

for i, s in enumerate(S, 1):
    if tot == 0:
        cnt += 1
        tot += 1
    tot -= 1
    tot += s
    if i == k:
        print(cnt)
        exit()
0