結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー mkawa2mkawa2
提出日時 2022-06-18 18:01:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 979 ms / 3,000 ms
コード長 2,216 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,640 KB
実行使用メモリ 152,388 KB
最終ジャッジ日時 2024-04-18 15:27:27
合計ジャッジ時間 20,611 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,736 KB
testcase_01 AC 37 ms
52,864 KB
testcase_02 AC 53 ms
71,296 KB
testcase_03 AC 394 ms
107,136 KB
testcase_04 AC 461 ms
103,460 KB
testcase_05 AC 396 ms
103,676 KB
testcase_06 AC 547 ms
117,504 KB
testcase_07 AC 621 ms
121,376 KB
testcase_08 AC 498 ms
107,420 KB
testcase_09 AC 608 ms
120,364 KB
testcase_10 AC 526 ms
111,532 KB
testcase_11 AC 359 ms
97,856 KB
testcase_12 AC 597 ms
111,340 KB
testcase_13 AC 351 ms
94,848 KB
testcase_14 AC 425 ms
107,592 KB
testcase_15 AC 355 ms
96,156 KB
testcase_16 AC 513 ms
112,832 KB
testcase_17 AC 842 ms
135,348 KB
testcase_18 AC 720 ms
128,752 KB
testcase_19 AC 825 ms
135,912 KB
testcase_20 AC 231 ms
95,224 KB
testcase_21 AC 303 ms
103,964 KB
testcase_22 AC 414 ms
99,600 KB
testcase_23 AC 281 ms
96,972 KB
testcase_24 AC 347 ms
94,960 KB
testcase_25 AC 731 ms
122,688 KB
testcase_26 AC 732 ms
127,024 KB
testcase_27 AC 217 ms
86,528 KB
testcase_28 AC 66 ms
75,788 KB
testcase_29 AC 654 ms
152,388 KB
testcase_30 AC 427 ms
149,676 KB
testcase_31 AC 396 ms
112,256 KB
testcase_32 AC 979 ms
146,436 KB
testcase_33 AC 867 ms
150,288 KB
testcase_34 AC 843 ms
150,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

class BitSum:
    def __init__(self, n):
        self.n = n+1
        self.table = [0]*self.n

    def add(self, i, x):
        i += 1
        while i < self.n:
            self.table[i] += x
            i += i & -i

    # [0,i]の和
    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

    # [l,r)の和
    def sumlr(self, l, r):
        if l >= r: return 0
        if l == 0: return self.sum(r-1)
        return self.sum(r-1)-self.sum(l-1)

    # 数列を度数分布とみたときに、x番目がどのインデックスにあるかを返す
    # xが大きすぎるときは配列の長さnを返す
    def rank(self, x):
        idx = 0
        d = 1 << (self.n-1).bit_length()-1
        while d:
            if idx+d < self.n and self.table[idx+d] < x:
                x -= self.table[idx+d]
                idx |= d
            d >>= 1
        return idx

n, k, q = LI()

if k == 0:
    for _ in range(q): print(-1)
    exit()

dd = [[] for _ in range(n+1)]
cc = []
for j in range(k):
    l, r, c, h = LI()
    l -= 1
    dd[l].append((j, h))
    dd[r].append((j, -h))
    cc.append(c)

xx = [[] for _ in range(n)]
for qi in range(q):
    i, x = LI()
    i -= 1
    xx[i].append((qi, x))

ans = [-1]*q
bit = BitSum(k)
for i in range(n):
    for j, d in dd[i]: bit.add(j, d)
    for qi, x in xx[i]:
        j = bit.rank(x)
        if j < k: ans[qi] = cc[j]

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