結果

問題 No.1703 Much Matching
ユーザー lam6er
提出日時 2025-03-20 20:17:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 126,044 KB
最終ジャッジ日時 2025-03-20 20:18:27
合計ジャッジ時間 26,532 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 23 TLE * 3 -- * 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