結果

問題 No.1703 Much Matching
コンテスト
ユーザー ntuda
提出日時 2025-11-01 16:02:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,207 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 198,696 KB
最終ジャッジ日時 2025-11-01 16:03:05
合計ジャッジ時間 10,702 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
N,M,Q = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(Q)]
E = [[] for _ in range(M)]
for a, b in AB:
    a -= 1
    b -= 1
    E[b].append(a)

X = []
for i in range(M):
    if not E[i]:
        continue
    E[i].sort(reverse = True)
    for s in E[i]:
        if not X:
            X.append(s)
        else:
            a = bisect_left(X,s)
            if a == len(X):
                X.append(s)
            else:
                X[a] = s
print(len(X))


0