提出 #48412016


ソースコード 拡げる

_,M=map(int,input().split())
S=input()

muji_ok=M  # 無地/洗濯済み
muji_ng=0  # 無地/着用済み
logo_ok=0  # ロゴ/洗濯済み
logo_ng=0  # ロゴ/着用済み
for c in S:
  if c=='0':
    # 洗濯をし、全てのngがokになる
    muji_ok+=muji_ng
    muji_ng=0
    logo_ok+=logo_ng
    logo_ng=0
  elif c=='1':
    if muji_ok:
      # 無地のTシャツがあるなら着る
      muji_ok-=1
      muji_ng+=1
    elif logo_ok:
      # ロゴ入りのTシャツがあるなら着る
      logo_ok-=1
      logo_ng+=1
    else:
      # 着るものがないならロゴ入りのTシャツを買って着る
      logo_ng+=1
  elif c=='2':
    if logo_ok:
      # ロゴ入りのTシャツがあるなら着る
      logo_ok-=1
      logo_ng+=1
    else:
      # 着るものがないならロゴ入りのTシャツを買って着る
      logo_ng+=1

print(logo_ok+logo_ng)

提出情報

提出日時
問題 C - T-shirts
ユーザ kyopro_friends
言語 Python (PyPy 3.10-v7.3.12)
得点 300
コード長 925 Byte
結果 AC
実行時間 70 ms
メモリ 76880 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 43
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 58 ms 76672 KiB
example_01.txt AC 63 ms 76704 KiB
example_02.txt AC 60 ms 76880 KiB
hand_00.txt AC 61 ms 76520 KiB
hand_01.txt AC 66 ms 76476 KiB
hand_02.txt AC 64 ms 76524 KiB
hand_03.txt AC 62 ms 76800 KiB
hand_04.txt AC 61 ms 76516 KiB
hand_05.txt AC 60 ms 76388 KiB
hand_06.txt AC 61 ms 76556 KiB
hand_07.txt AC 60 ms 76824 KiB
hand_08.txt AC 62 ms 76432 KiB
hand_09.txt AC 65 ms 76376 KiB
random_00.txt AC 62 ms 76564 KiB
random_01.txt AC 67 ms 76532 KiB
random_02.txt AC 66 ms 76824 KiB
random_03.txt AC 62 ms 76412 KiB
random_04.txt AC 70 ms 76676 KiB
random_05.txt AC 66 ms 76712 KiB
random_06.txt AC 67 ms 76504 KiB
random_07.txt AC 60 ms 76528 KiB
random_08.txt AC 65 ms 76548 KiB
random_09.txt AC 66 ms 76580 KiB
random_10.txt AC 63 ms 76592 KiB
random_11.txt AC 63 ms 76336 KiB
random_12.txt AC 62 ms 76344 KiB
random_13.txt AC 61 ms 76748 KiB
random_14.txt AC 60 ms 76592 KiB
random_15.txt AC 64 ms 76568 KiB
random_16.txt AC 64 ms 76548 KiB
random_17.txt AC 63 ms 76668 KiB
random_18.txt AC 65 ms 76596 KiB
random_19.txt AC 63 ms 76728 KiB
random_20.txt AC 62 ms 76728 KiB
random_21.txt AC 61 ms 76600 KiB
random_22.txt AC 58 ms 76720 KiB
random_23.txt AC 59 ms 76448 KiB
random_24.txt AC 64 ms 76660 KiB
random_25.txt AC 63 ms 76624 KiB
random_26.txt AC 61 ms 76680 KiB
random_27.txt AC 60 ms 76532 KiB
random_28.txt AC 60 ms 76276 KiB
random_29.txt AC 59 ms 76576 KiB