結果

問題 No.78 クジ付きアイスバー
コンテスト
ユーザー 👑 rin204
提出日時 2022-07-05 16:55:39
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 25 ms / 5,000 ms
+ 539µs
コード長 498 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 76 ms
コンパイル使用メモリ 81,716 KB
実行使用メモリ 56,304 KB
最終ジャッジ日時 2026-10-10 15:42:15
合計ジャッジ時間 3,430 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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