結果

問題 No.1703 Much Matching
コンテスト
ユーザー norioc
提出日時 2026-06-09 02:20:41
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 661 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 344 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 239,348 KB
最終ジャッジ日時 2026-06-09 02:22:00
合計ジャッジ時間 18,738 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33 TLE * 1 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_left


def lis(a: list) -> list:
    n = len(a)
    ranks = [0] * n  # ranks[i] : A[i] が LIS の何番目か
    dp = [INF] * n
    for i in range(n):
        ranks[i] = bisect_left(dp, a[i])
        dp[ranks[i]] = a[i]

    p = max(ranks)
    res = [None] * (p+1)
    for i in reversed(range(n)):
        if ranks[i] == p:
            res[p] = a[i]
            p -= 1

    return res


INF = 1 << 62
N, M, Q = map(int, input().split())

xs = []
for i in range(Q):
    A, B = map(lambda x: int(x)-1, input().split())
    xs.append((A, B))

seq = [b for _, b in sorted(xs, key=lambda x: (x[0], -x[1]))]
res = lis(seq)
print(len(res))
0