結果

問題 No.2422 regisys?
ユーザー miya145592miya145592
提出日時 2023-08-12 15:06:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,518 ms / 2,000 ms
コード長 2,112 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 152,320 KB
最終ジャッジ日時 2024-04-30 08:06:47
合計ジャッジ時間 30,746 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,356 KB
testcase_01 AC 41 ms
55,548 KB
testcase_02 AC 46 ms
61,500 KB
testcase_03 AC 40 ms
54,468 KB
testcase_04 AC 50 ms
61,612 KB
testcase_05 AC 49 ms
62,608 KB
testcase_06 AC 51 ms
63,252 KB
testcase_07 AC 44 ms
54,948 KB
testcase_08 AC 50 ms
61,676 KB
testcase_09 AC 41 ms
53,732 KB
testcase_10 AC 43 ms
53,812 KB
testcase_11 AC 45 ms
59,556 KB
testcase_12 AC 39 ms
53,804 KB
testcase_13 AC 51 ms
63,276 KB
testcase_14 AC 45 ms
60,688 KB
testcase_15 AC 47 ms
61,704 KB
testcase_16 AC 47 ms
61,228 KB
testcase_17 AC 42 ms
54,284 KB
testcase_18 AC 45 ms
61,552 KB
testcase_19 AC 50 ms
63,068 KB
testcase_20 AC 50 ms
63,616 KB
testcase_21 AC 42 ms
54,116 KB
testcase_22 AC 43 ms
56,096 KB
testcase_23 AC 51 ms
62,212 KB
testcase_24 AC 47 ms
62,788 KB
testcase_25 AC 48 ms
61,712 KB
testcase_26 AC 41 ms
53,356 KB
testcase_27 AC 44 ms
60,272 KB
testcase_28 AC 46 ms
59,380 KB
testcase_29 AC 52 ms
61,988 KB
testcase_30 AC 43 ms
54,888 KB
testcase_31 AC 549 ms
98,580 KB
testcase_32 AC 771 ms
115,300 KB
testcase_33 AC 493 ms
96,760 KB
testcase_34 AC 399 ms
91,948 KB
testcase_35 AC 565 ms
102,340 KB
testcase_36 AC 598 ms
104,288 KB
testcase_37 AC 770 ms
109,692 KB
testcase_38 AC 614 ms
111,136 KB
testcase_39 AC 445 ms
96,368 KB
testcase_40 AC 365 ms
87,164 KB
testcase_41 AC 453 ms
93,640 KB
testcase_42 AC 897 ms
115,912 KB
testcase_43 AC 602 ms
98,972 KB
testcase_44 AC 976 ms
117,852 KB
testcase_45 AC 818 ms
112,152 KB
testcase_46 AC 964 ms
117,992 KB
testcase_47 AC 693 ms
108,876 KB
testcase_48 AC 966 ms
132,780 KB
testcase_49 AC 830 ms
111,332 KB
testcase_50 AC 881 ms
133,776 KB
testcase_51 AC 1,308 ms
132,740 KB
testcase_52 AC 500 ms
99,500 KB
testcase_53 AC 1,022 ms
118,464 KB
testcase_54 AC 1,361 ms
141,188 KB
testcase_55 AC 1,034 ms
121,656 KB
testcase_56 AC 922 ms
124,316 KB
testcase_57 AC 1,456 ms
142,340 KB
testcase_58 AC 1,516 ms
152,320 KB
testcase_59 AC 1,470 ms
142,364 KB
testcase_60 AC 1,518 ms
141,948 KB
testcase_61 AC 40 ms
53,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# n=1はおかしい
class SegTree:
    def __init__(self, op, e, n, v=None):
        self._n = n
        self._op = op
        self._e = e
        self._log = (n - 1).bit_length()
        self._size = 1 << self._log
        self._d = [self._e()] * (self._size << 1)
        if v is not None:
            for i in range(self._n):
                self._d[self._size + i] = v[i]
            for i in range(self._size - 1, 0, -1):
                self._d[i] = self._op(self._d[i << 1], self._d[i << 1 | 1])

    def set(self, p, x):
        p += self._size
        self._d[p] = x
        while p:
            l, r = p, p^1
            if l > r: l, r = r, l
            self._d[p >> 1] = self._op(self._d[l], self._d[r])
            p >>= 1

    def get(self, p):
        return self._d[p + self._size]

    #[l, r)の区間で求める
    def prod(self, l, r):
        sml, smr = self._e(), self._e()
        l += self._size
        r += self._size
        while l < r:
            if l & 1:
                sml = self._op(sml, self._d[l])
                l += 1
            if r & 1:
                r -= 1
                smr = self._op(self._d[r], smr)
            l >>= 1
            r >>= 1
        return self._op(sml, smr)

    def all_prod(self):
        return self._d[1]

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

def e():
    return (-1, -1)

import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
TC = [list(map(int, input().split())) for _ in range(M)]
ST = SegTree(op, e, N)
AB = []
for a, b in zip(A, B):
    AB.append((a, b))
AB.sort()
for i in range(N):
    a, b = AB[i]
    ST.set(i, (b, i))

TC.sort(key=lambda x:x[1])
U = []
V = []
for t, c in TC:
    if t==0:
        U.append(c)
    else:
        V.append(c)

INF = 10**10
for c in U:
    pos = bisect.bisect_right(AB, (c, INF))
    b, i = ST.prod(0, pos)
    if i!=-1:
        ST.set(i, (-1, -1))

BB = []
for i in range(N):
    b, _ = ST.get(i)
    if b!=-1:
        BB.append(b)
BB.sort(reverse=True)
#print(BB)
for c in V:
    if BB and BB[-1]<=c:
        BB.pop()

print(len(BB))
0