結果

問題 No.78 クジ付きアイスバー
ユーザー buey_tbuey_t
提出日時 2023-04-24 12:11:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,922 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 83,716 KB
最終ジャッジ日時 2023-08-08 08:28:42
合計ジャッジ時間 28,694 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 232 ms
82,596 KB
testcase_01 AC 235 ms
82,548 KB
testcase_02 AC 235 ms
82,544 KB
testcase_03 AC 232 ms
82,568 KB
testcase_04 AC 234 ms
82,560 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 239 ms
82,528 KB
testcase_15 AC 238 ms
82,516 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 237 ms
82,540 KB
testcase_24 AC 238 ms
82,804 KB
testcase_25 AC 242 ms
82,544 KB
testcase_26 AC 237 ms
82,532 KB
testcase_27 AC 234 ms
82,540 KB
testcase_28 AC 238 ms
82,428 KB
testcase_29 WA -
testcase_30 AC 237 ms
82,432 KB
testcase_31 AC 234 ms
82,544 KB
testcase_32 AC 231 ms
82,440 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 491 ms
82,984 KB
testcase_36 WA -
testcase_37 AC 502 ms
83,032 KB
testcase_38 AC 238 ms
82,512 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