結果

問題 No.1703 Much Matching
ユーザー gew1fw
提出日時 2025-06-12 12:54:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 578 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 82,848 KB
実行使用メモリ 231,156 KB
最終ジャッジ日時 2025-06-12 12:59:47
合計ジャッジ時間 22,783 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32 TLE * 2 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

n, m, q = map(int, input().split())
pairs = []
for _ in range(q):
    a, b = map(int, input().split())
    pairs.append((a, b))

# Sort by a ascending, then b descending to handle same a's correctly
pairs.sort(key=lambda x: (x[0], -x[1]))

# Extract the list of y's (b values) in the sorted order
ys = [b for a, b in pairs]

# Compute the longest strictly increasing subsequence using binary search
tails = []
for y in ys:
    idx = bisect.bisect_left(tails, y)
    if idx == len(tails):
        tails.append(y)
    else:
        tails[idx] = y

print(len(tails))
0