結果

問題 No.1703 Much Matching
ユーザー mkawa2mkawa2
提出日時 2021-10-08 22:26:01
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,303 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 162,216 KB
最終ジャッジ日時 2023-09-30 10:56:17
合計ジャッジ時間 26,514 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,980 KB
testcase_01 AC 72 ms
71,416 KB
testcase_02 AC 73 ms
71,556 KB
testcase_03 AC 72 ms
71,552 KB
testcase_04 AC 80 ms
75,912 KB
testcase_05 AC 75 ms
71,316 KB
testcase_06 AC 1,232 ms
123,168 KB
testcase_07 AC 133 ms
80,028 KB
testcase_08 AC 1,291 ms
125,460 KB
testcase_09 AC 1,483 ms
133,196 KB
testcase_10 AC 245 ms
85,220 KB
testcase_11 AC 334 ms
88,912 KB
testcase_12 AC 130 ms
78,868 KB
testcase_13 AC 559 ms
98,668 KB
testcase_14 AC 103 ms
78,208 KB
testcase_15 AC 279 ms
87,108 KB
testcase_16 AC 798 ms
107,144 KB
testcase_17 AC 914 ms
111,772 KB
testcase_18 AC 103 ms
77,964 KB
testcase_19 TLE -
testcase_20 AC 275 ms
86,276 KB
testcase_21 TLE -
testcase_22 AC 886 ms
110,708 KB
testcase_23 AC 653 ms
102,232 KB
testcase_24 AC 101 ms
77,840 KB
testcase_25 AC 151 ms
80,560 KB
testcase_26 AC 443 ms
93,784 KB
testcase_27 AC 989 ms
114,860 KB
testcase_28 AC 1,922 ms
147,596 KB
testcase_29 AC 364 ms
90,056 KB
testcase_30 AC 536 ms
96,868 KB
testcase_31 AC 126 ms
79,288 KB
testcase_32 AC 1,012 ms
114,888 KB
testcase_33 AC 653 ms
102,440 KB
testcase_34 AC 133 ms
79,164 KB
testcase_35 AC 216 ms
83,836 KB
testcase_36 TLE -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**19
# md = 998244353
md = 10**9+7

class BitMax:
    def __init__(self, n):
        self.inf = 10**16
        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