結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー tassei903tassei903
提出日時 2022-06-18 16:22:52
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,114 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 195,928 KB
最終ジャッジ日時 2023-08-27 22:00:37
合計ジャッジ時間 58,913 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,512 KB
testcase_01 AC 79 ms
71,392 KB
testcase_02 AC 77 ms
71,400 KB
testcase_03 AC 981 ms
117,284 KB
testcase_04 AC 1,375 ms
133,896 KB
testcase_05 AC 1,381 ms
128,128 KB
testcase_06 AC 1,608 ms
139,332 KB
testcase_07 AC 1,988 ms
154,984 KB
testcase_08 AC 1,312 ms
132,288 KB
testcase_09 AC 1,490 ms
138,384 KB
testcase_10 AC 1,743 ms
145,628 KB
testcase_11 AC 1,099 ms
118,716 KB
testcase_12 AC 1,756 ms
147,460 KB
testcase_13 AC 1,103 ms
123,584 KB
testcase_14 AC 1,699 ms
145,812 KB
testcase_15 AC 1,160 ms
122,760 KB
testcase_16 AC 1,479 ms
136,088 KB
testcase_17 AC 2,653 ms
180,072 KB
testcase_18 AC 2,200 ms
164,368 KB
testcase_19 AC 2,597 ms
177,528 KB
testcase_20 AC 428 ms
92,180 KB
testcase_21 AC 628 ms
100,216 KB
testcase_22 AC 1,325 ms
133,956 KB
testcase_23 AC 589 ms
100,492 KB
testcase_24 AC 1,170 ms
122,520 KB
testcase_25 AC 2,512 ms
177,428 KB
testcase_26 AC 2,288 ms
169,152 KB
testcase_27 AC 569 ms
97,648 KB
testcase_28 AC 925 ms
118,332 KB
testcase_29 AC 1,562 ms
189,168 KB
testcase_30 AC 897 ms
180,660 KB
testcase_31 AC 935 ms
118,772 KB
testcase_32 TLE -
testcase_33 AC 2,339 ms
195,180 KB
testcase_34 AC 2,325 ms
195,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
######################################################################## Binary Indexed Tree (Fenwick Tree)
# 0-indexed
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        assert 0 <= i < self.n
        i = i+1
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def set(self, i, x):
        assert 0 <= i <= self.n
        self.add(i,x-self.get(i))
    def get(self, i, j=None):# j=Noneのときiを取得, [i, j)の和を取得
        if j is None:
            return self.el[i+1]
        return self.sum(j) - self.sum(i)
    def lower_bound(self, k):# a[0],…,a[i]>kなる最小のi
        n = self.n
        x = 0
        r = 1
        while r <= n:r <<= 1
        size = r
        while size:
            if x + size <= n and self.data[x+size] <= k:
                k-=self.data[x+size]
                x += size
            size >>= 1
        return x
    def debug(self):
        res = []
        n = self.n
        for i in range(n):
            res.append(self.get(i))
        print(*res)

N,K,Q = na()
eve = []
color = [-1]*K
for i in range(K):
    l,r,c,h = na()
    color[i] = c
    eve.append((l, 0, i, h))
    eve.append((r, 2, i, h))
ans = [-1]*Q
for j in range(Q):
    i, x = na()
    eve.append((i, 1, j, x-1))

eve = sorted(eve)
bit = BIT(K)
for i, p, j, h in eve:
    if p == 0:
        bit.add(j, h)
    elif p == 2:
        bit.add(j, -h)
    else:
        x = bit.lower_bound(h)
        #bit.debug()
        #print(x)
        if x == K:
            ans[j] = -1
        else:
            ans[j] = color[x]

print(*ans,sep="\n")
0