結果

問題 No.1703 Much Matching
ユーザー lam6er
提出日時 2025-03-20 18:40:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,644 KB
実行使用メモリ 125,916 KB
最終ジャッジ日時 2025-03-20 18:41:34
合計ジャッジ時間 22,794 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 25 TLE * 1 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

n, m, q = map(int, input().split())
pairs = [tuple(map(int, input().split())) for _ in range(q)]
pairs.sort()
groups = []
current_a = None
current_ys = []
for a, b in pairs:
    if a != current_a:
        if current_a is not None:
            groups.append(current_ys)
        current_a = a
        current_ys = []
    current_ys.append(b)
if current_ys:
    groups.append(current_ys)

dp = []
for ys in groups:
    if not dp:
        if ys:
            dp.append(ys[0])
    else:
        last_y = dp[-1]
        idx = bisect.bisect_right(ys, last_y)
        if idx < len(ys):
            dp.append(ys[idx])

print(len(dp))
0