結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー mkawa2mkawa2
提出日時 2022-06-18 17:56:15
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 2,158 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 150,316 KB
最終ジャッジ日時 2024-04-18 15:21:00
合計ジャッジ時間 11,343 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,480 KB
testcase_01 AC 40 ms
52,736 KB
testcase_02 AC 53 ms
72,784 KB
testcase_03 AC 441 ms
108,320 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 492 ms
108,000 KB
testcase_09 AC 577 ms
120,620 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 768 ms
128,704 KB
testcase_19 RE -
testcase_20 AC 246 ms
98,688 KB
testcase_21 AC 345 ms
107,992 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 419 ms
112,016 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 886 ms
150,316 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()

dd = [[] for _ in range(n)]
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(n)
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