結果

問題 No.1703 Much Matching
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-10-08 22:29:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,437 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 163,424 KB
最終ジャッジ日時 2023-09-30 11:08:23
合計ジャッジ時間 29,919 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,344 KB
testcase_01 AC 73 ms
70,776 KB
testcase_02 AC 74 ms
71,264 KB
testcase_03 AC 79 ms
71,088 KB
testcase_04 AC 95 ms
75,792 KB
testcase_05 AC 87 ms
76,032 KB
testcase_06 AC 1,408 ms
123,176 KB
testcase_07 AC 176 ms
80,380 KB
testcase_08 AC 1,436 ms
125,188 KB
testcase_09 AC 1,659 ms
133,432 KB
testcase_10 AC 303 ms
85,240 KB
testcase_11 AC 394 ms
88,960 KB
testcase_12 AC 168 ms
79,584 KB
testcase_13 AC 660 ms
98,452 KB
testcase_14 AC 134 ms
78,152 KB
testcase_15 AC 338 ms
86,716 KB
testcase_16 AC 909 ms
107,092 KB
testcase_17 AC 1,056 ms
112,188 KB
testcase_18 AC 137 ms
77,872 KB
testcase_19 TLE -
testcase_20 AC 343 ms
86,772 KB
testcase_21 TLE -
testcase_22 AC 998 ms
110,616 KB
testcase_23 AC 764 ms
102,064 KB
testcase_24 AC 133 ms
77,764 KB
testcase_25 AC 192 ms
80,528 KB
testcase_26 AC 524 ms
93,736 KB
testcase_27 AC 1,160 ms
115,088 KB
testcase_28 TLE -
testcase_29 AC 434 ms
90,840 KB
testcase_30 AC 606 ms
96,844 KB
testcase_31 AC 160 ms
78,960 KB
testcase_32 AC 1,152 ms
114,868 KB
testcase_33 AC 759 ms
102,256 KB
testcase_34 AC 169 ms
79,452 KB
testcase_35 AC 266 ms
83,796 KB
testcase_36 TLE -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

class SegTree:
    """ define what you want to do with 0 index, ex) size = tree_size, func = min or max, sta = default_value """
    
    def __init__(self,size,func,sta):
        self.n = size
        self.size = 1 << size.bit_length()
        self.func = func
        self.sta = sta
        self.tree = [sta]*(2*self.size)

    def build(self, list):
        """ set list and update tree"""
        for i,x in enumerate(list,self.size):
            self.tree[i] = x

        for i in range(self.size-1,0,-1):
            self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1])

    def set(self,i,x):
        i += self.size
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1])

    
    def get(self,l,r):
        """ take the value of [l r) with func (min or max)"""
        l += self.size
        r += self.size
        res = self.sta

        while l < r:
            if l & 1:
                res = self.func(self.tree[l],res)
                l += 1
            if r & 1:
                res = self.func(self.tree[r-1],res)
            l >>= 1
            r >>= 1
        return res

n,m,q = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(q)]
AB.sort(key=lambda x:(x[0],-x[1]))

def func(x,y):
    return max(x,y)

seg = SegTree(m+5,func,0)

for a,b in AB:
    seg.set(b,seg.get(0,b)+1)
print(seg.get(0,m+2))
0