結果

問題 No.3453 Crape Shop
コンテスト
ユーザー titia
提出日時 2026-03-01 01:27:24
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 514 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 568 ms
コンパイル使用メモリ 20,952 KB
実行使用メモリ 16,476 KB
最終ジャッジ日時 2026-03-01 01:27:29
合計ジャッジ時間 4,729 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

N=int(input())
A,B=list(map(int,input().split()))
P=list(map(int,input().split()))

ANS=-1

for i in range(N):
    p=P[i]

    if p==1:
        if A>=1:
            A-=1
        else:
            ANS=i+1
            break
    elif p==2:
        if B>=1:
            B-=1
        else:
            ANS=i+1
            break
    else:
        if A>=1 and B>=1:
            B-=1
            A-=1
        else:
            ANS=i+1
            break

print(ANS)
        
        
0