結果

問題 No.2422 regisys?
ユーザー FromBooska
提出日時 2023-08-20 18:01:54
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,414 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 191,576 KB
最終ジャッジ日時 2024-11-30 21:46:54
合計ジャッジ時間 97,053 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31 TLE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

# マッチング、最大流ではMLEした
# Ford_FulkersonができるのはN100前後だけ
# 公式解説はまったく違うやり方
# 一般の人について、所持金の低い順に走査
# それぞれの購買者について、買うことのできる商品の中で最も「MMA 部員が購入できる値段」が高いものを購入
# MMA 部員について、所持金の低い順に走査
# それぞれの購買者について、買うことのできる商品があったら購入
# N<1000なので二重ループ可能か

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
items = []
for i in range(N):
    items.append([A[i], B[i], 1])

people0 = []
people1 = []
for i in range(M):
    t, c = map(int, input().split())
    if t == 0:
        people0.append(c)
    elif t == 1:
        people1.append(c)
people0.sort()
people1.sort()
        
for c in people0:
    b_mx = 0
    b_mx_idx = -1
    for i in range(N):
        a, b, d = items[i]
        if d == 1 and a <= c:
            if b > b_mx:
                b_mx = b
                b_mx_idx = i
    if b_mx_idx >= 0:
        items[b_mx_idx][2] = 0
            
for c in people1:
    for i in range(N):
        a, b, d = items[i]
        if d == 1 and b <= c:
            items[i][2] = 0
            break

ans = 0
for a, b, d in items:
    if d == 1:
        ans += 1
print(ans)

0