結果

問題 No.1703 Much Matching
ユーザー mkawa2
提出日時 2021-10-08 22:28:30
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 827 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,568 KB
実行使用メモリ 242,172 KB
最終ジャッジ日時 2024-07-23 05:08:47
合計ジャッジ時間 26,416 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 TLE * 4 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
md = 10**9+7

class BitMax:
    def __init__(self, n):
        self.inf = 10**9
        self.n = n
        self.table = [-self.inf]*(self.n+1)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            if x > self.table[i]: self.table[i] = x
            i += i & -i

    def max(self, i):
        i += 1
        res = -self.inf
        while i > 0:
            if self.table[i] > res: res = self.table[i]
            i -= i & -i
        return res

n, m, q = LI()
ab = LLI(q)
ab.sort(key=lambda x: (x[0], -x[1]))

bit = BitMax(m+5)
bit.update(0, 0)

for a, b in ab:
    pre = bit.max(b-1)
    bit.update(b, pre+1)

print(bit.max(m+4))
0