結果

問題 No.1703 Much Matching
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-10-08 22:32:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,500 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 86,696 KB
実行使用メモリ 240,692 KB
最終ジャッジ日時 2023-09-30 11:27:05
合計ジャッジ時間 27,511 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,632 KB
testcase_01 AC 75 ms
71,016 KB
testcase_02 AC 74 ms
71,220 KB
testcase_03 AC 76 ms
70,984 KB
testcase_04 AC 88 ms
75,756 KB
testcase_05 AC 83 ms
75,628 KB
testcase_06 AC 1,264 ms
123,140 KB
testcase_07 AC 155 ms
79,544 KB
testcase_08 AC 1,356 ms
125,352 KB
testcase_09 AC 1,580 ms
132,028 KB
testcase_10 AC 267 ms
85,016 KB
testcase_11 AC 361 ms
88,696 KB
testcase_12 AC 148 ms
79,000 KB
testcase_13 AC 601 ms
98,504 KB
testcase_14 AC 120 ms
77,796 KB
testcase_15 AC 305 ms
86,868 KB
testcase_16 AC 817 ms
106,876 KB
testcase_17 AC 957 ms
111,384 KB
testcase_18 AC 118 ms
77,608 KB
testcase_19 TLE -
testcase_20 AC 296 ms
86,412 KB
testcase_21 TLE -
testcase_22 AC 938 ms
110,216 KB
testcase_23 AC 716 ms
101,900 KB
testcase_24 AC 120 ms
77,620 KB
testcase_25 AC 172 ms
80,648 KB
testcase_26 AC 477 ms
93,028 KB
testcase_27 AC 1,049 ms
114,768 KB
testcase_28 TLE -
testcase_29 AC 397 ms
90,188 KB
testcase_30 AC 558 ms
96,520 KB
testcase_31 AC 143 ms
79,296 KB
testcase_32 AC 1,067 ms
114,976 KB
testcase_33 AC 699 ms
101,192 KB
testcase_34 AC 148 ms
78,616 KB
testcase_35 AC 237 ms
83,704 KB
testcase_36 TLE -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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):
    if x > y:
        return x
    return 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