結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
85,092 KB
testcase_01 AC 123 ms
85,304 KB
testcase_02 AC 120 ms
85,120 KB
testcase_03 AC 119 ms
85,196 KB
testcase_04 AC 120 ms
85,392 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 114 ms
85,132 KB
testcase_15 AC 114 ms
85,324 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 127 ms
85,128 KB
testcase_24 AC 113 ms
85,356 KB
testcase_25 AC 116 ms
85,244 KB
testcase_26 AC 117 ms
85,024 KB
testcase_27 AC 120 ms
85,244 KB
testcase_28 AC 117 ms
85,296 KB
testcase_29 AC 124 ms
85,212 KB
testcase_30 AC 122 ms
85,540 KB
testcase_31 AC 127 ms
85,264 KB
testcase_32 AC 151 ms
89,980 KB
testcase_33 AC 149 ms
89,968 KB
testcase_34 WA -
testcase_35 AC 262 ms
90,156 KB
testcase_36 WA -
testcase_37 AC 306 ms
89,812 KB
testcase_38 AC 118 ms
85,304 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