結果

問題 No.78 クジ付きアイスバー
ユーザー buey_tbuey_t
提出日時 2023-04-24 12:14:03
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,915 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 83,460 KB
最終ジャッジ日時 2023-08-08 08:35:01
合計ジャッジ時間 13,476 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 245 ms
82,444 KB
testcase_01 AC 236 ms
82,620 KB
testcase_02 AC 237 ms
82,576 KB
testcase_03 AC 233 ms
82,588 KB
testcase_04 AC 235 ms
82,504 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 240 ms
82,116 KB
testcase_15 AC 236 ms
82,444 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 235 ms
82,180 KB
testcase_24 AC 237 ms
82,576 KB
testcase_25 AC 236 ms
82,576 KB
testcase_26 AC 240 ms
82,440 KB
testcase_27 AC 235 ms
82,588 KB
testcase_28 AC 236 ms
82,356 KB
testcase_29 AC 237 ms
82,468 KB
testcase_30 AC 236 ms
82,524 KB
testcase_31 AC 233 ms
82,644 KB
testcase_32 AC 244 ms
83,268 KB
testcase_33 AC 254 ms
82,796 KB
testcase_34 WA -
testcase_35 AC 440 ms
83,100 KB
testcase_36 WA -
testcase_37 AC 468 ms
83,048 KB
testcase_38 AC 237 ms
82,584 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 + 1000000 < 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