結果

問題 No.1703 Much Matching
ユーザー rlangevinrlangevin
提出日時 2023-03-01 12:35:25
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,187 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 139,624 KB
最終ジャッジ日時 2023-10-14 17:07:48
合計ジャッジ時間 9,764 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,600 KB
testcase_01 AC 75 ms
71,520 KB
testcase_02 AC 75 ms
71,204 KB
testcase_03 AC 76 ms
71,236 KB
testcase_04 AC 91 ms
75,888 KB
testcase_05 AC 87 ms
75,704 KB
testcase_06 AC 340 ms
85,256 KB
testcase_07 RE -
testcase_08 AC 327 ms
85,968 KB
testcase_09 RE -
testcase_10 AC 144 ms
78,232 KB
testcase_11 RE -
testcase_12 AC 120 ms
78,012 KB
testcase_13 RE -
testcase_14 AC 111 ms
77,584 KB
testcase_15 RE -
testcase_16 AC 245 ms
81,548 KB
testcase_17 RE -
testcase_18 AC 110 ms
77,512 KB
testcase_19 RE -
testcase_20 AC 149 ms
78,340 KB
testcase_21 RE -
testcase_22 AC 258 ms
82,532 KB
testcase_23 RE -
testcase_24 AC 112 ms
78,028 KB
testcase_25 AC 127 ms
78,024 KB
testcase_26 AC 183 ms
79,416 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 199 ms
79,652 KB
testcase_31 RE -
testcase_32 AC 285 ms
83,344 KB
testcase_33 AC 221 ms
80,628 KB
testcase_34 AC 122 ms
77,888 KB
testcase_35 RE -
testcase_36 AC 957 ms
139,624 KB
testcase_37 AC 98 ms
75,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

class SegmentTree:
    def __init__(self, size, f=max, default=0):
        self.size = 2**(size-1).bit_length() 
        self.default = default
        self.dat = [default]*(self.size*2) 
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres) 
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

N, M, Q = map(int, readline().split())
D = [[] for i in range(M)]
for i in range(Q):
    A, B = map(int, readline().split())
    A, B = A - 1, B - 1
    D[A].append(B)

dp = SegmentTree(M)
for i in range(M):
    for B in sorted(D[i], reverse=True):
        val = dp.query(0, B)
        dp.update(B, val + 1)

print(dp.query(0, M))
0