結果

問題 No.78 クジ付きアイスバー
ユーザー buey_tbuey_t
提出日時 2023-04-24 12:11:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,922 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 90,064 KB
最終ジャッジ日時 2024-04-26 01:54:19
合計ジャッジ時間 22,362 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
85,148 KB
testcase_01 AC 122 ms
85,248 KB
testcase_02 AC 120 ms
85,104 KB
testcase_03 AC 121 ms
85,260 KB
testcase_04 AC 123 ms
85,240 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 121 ms
85,192 KB
testcase_15 AC 122 ms
85,336 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 124 ms
85,128 KB
testcase_24 AC 122 ms
85,272 KB
testcase_25 AC 125 ms
85,248 KB
testcase_26 AC 126 ms
85,276 KB
testcase_27 AC 126 ms
85,236 KB
testcase_28 AC 126 ms
85,488 KB
testcase_29 WA -
testcase_30 AC 124 ms
85,268 KB
testcase_31 AC 122 ms
85,272 KB
testcase_32 AC 119 ms
85,592 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 354 ms
89,772 KB
testcase_36 WA -
testcase_37 AC 398 ms
89,904 KB
testcase_38 AC 122 ms
85,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
from heapq import heapify, heappop, heappush
from bisect import bisect_left, bisect_right
from copy import deepcopy
import copy
import random
from collections import deque,Counter,defaultdict
from itertools import permutations,combinations
from decimal import Decimal,ROUND_HALF_UP
#tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
from functools import lru_cache, reduce
#@lru_cache(maxsize=None)
from operator import add,sub,mul,xor,and_,or_,itemgetter
import sys
input = sys.stdin.readline
# .rstrip()
INF = 10**18
mod1 = 10**9+7
mod2 = 998244353

#DecimalならPython
#再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!


'''
周期性とかかな
ダブリンぐでもいけそうだけど
一周で何本もらえるのか
それで、Kをそれで割ることで、何箱使わないといけないかはわかる
そのあとは愚直でいい

いや、当たりを引き換える必要があるから
周期性が乱れる
一週目だけ特別なのか

当たりくじの数を記録しておいて、当たりくじがアイスバーの長さになるたびにやる
それで結構いい近似を得れる
そして、while now < K+N+atari でやる
'''

N,K = map(int, input().split())
S = list(input().rstrip())

atari = 0
for i in range(N):
    if S[i] == '1':
        atari += 1
    elif S[i] == '2':
        atari += 2

if atari >= N:
    print(1)
    exit()

now = 0
tmp = 0
cost = 0
while now + tmp + N + atari< K:
    now += N
    cost += N
    tmp += atari
    
    if tmp >= N:
        tmp -= N
        now += N
        tmp += atari

i = 0
while now < K:
    if tmp > 0:
        tmp -= 1
    else:
        cost += 1
    
    if S[i] == '1':
        tmp += 1
    elif S[i] == '2':
        tmp += 2
    
    now += 1
    i += 1
    
    if i == N:
        i = 0
    
print(cost)



















0