結果

問題 No.2422 regisys?
ユーザー gew1fw
提出日時 2025-06-12 19:20:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,194 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 132,360 KB
最終ジャッジ日時 2025-06-12 19:20:15
合計ジャッジ時間 12,745 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 58 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

type0 = []
type1 = []

for _ in range(m):
    t, c = map(int, input().split())
    if t == 0:
        type0.append(c)
    else:
        type1.append(c)

type0.sort()
type1.sort()

max0 = type0[-1] if type0 else 0
max1 = type1[-1] if type1 else 0

type0_products = []
type1_products = []

for a, b in zip(A, B):
    can0 = len(type0) > 0 and a <= max0
    can1 = len(type1) > 0 and b <= max1
    if can0 and can1:
        if a < b:
            type0_products.append(a)
        elif b < a:
            type1_products.append(b)
        else:
            type0_products.append(a)
    elif can0:
        type0_products.append(a)
    elif can1:
        type1_products.append(b)

def max_sell(products, buyers):
    products.sort()
    buyers.sort()
    i = j = count = 0
    while i < len(products) and j < len(buyers):
        if buyers[j] >= products[i]:
            count += 1
            i += 1
            j += 1
        else:
            j += 1
    return count

cnt0 = max_sell(type0_products, type0)
cnt1 = max_sell(type1_products, type1)

total_sold = cnt0 + cnt1
print(n - total_sold)
0