結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー mkawa2mkawa2
提出日時 2022-06-18 17:48:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,190 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 82,148 KB
実行使用メモリ 230,916 KB
最終ジャッジ日時 2024-04-18 15:12:26
合計ジャッジ時間 54,463 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,608 KB
testcase_01 AC 41 ms
52,736 KB
testcase_02 AC 40 ms
53,888 KB
testcase_03 AC 917 ms
126,404 KB
testcase_04 AC 1,275 ms
146,636 KB
testcase_05 WA -
testcase_06 AC 1,557 ms
155,664 KB
testcase_07 WA -
testcase_08 AC 1,297 ms
146,904 KB
testcase_09 AC 1,533 ms
154,088 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2,133 ms
190,684 KB
testcase_19 WA -
testcase_20 AC 395 ms
96,300 KB
testcase_21 AC 597 ms
108,160 KB
testcase_22 WA -
testcase_23 AC 573 ms
104,484 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 928 ms
127,096 KB
testcase_29 AC 1,588 ms
227,832 KB
testcase_30 AC 860 ms
218,956 KB
testcase_31 AC 943 ms
128,168 KB
testcase_32 TLE -
testcase_33 AC 2,344 ms
229,144 KB
testcase_34 AC 2,347 ms
229,148 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()
bit = BitSum(n)
task = []
cc = []
for j in range(k):
    l, r, c, h = LI()
    l -= 1
    task.append((l, 0, j, h))
    task.append((r, 0, j, -h))
    cc.append(c)
for j in range(q):
    i, x = LI()
    i -= 1
    task.append((i, 1, j, x))

ans = [0]*q
task.sort(key=lambda x: (x[0], x[1]))

for i, t, j, x in task:
    if t:
        qi = j
        j = bit.rank(x)
        if j == n: ans[qi] = -1
        else: ans[qi] = cc[j]
    else:
        bit.add(j, x)

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