結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー mkawa2mkawa2
提出日時 2022-06-17 23:06:40
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,930 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 121,136 KB
最終ジャッジ日時 2024-04-17 15:28:14
合計ジャッジ時間 14,429 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
60,160 KB
testcase_01 AC 49 ms
53,888 KB
testcase_02 AC 51 ms
57,216 KB
testcase_03 AC 2,739 ms
109,812 KB
testcase_04 TLE -
testcase_05 AC 869 ms
102,092 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

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 LF(): return list(map(float, 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

from collections import defaultdict

def add(i, a):
    i += 1
    while i <= n:
        bit[i] += a
        i += i & -i

def cumsum(i):
    res = 0
    i += 1
    while i > 0:
        res += bit[i]
        i -= i & -i
    return res

n, k, q = LI()
lrch = []
for _ in range(k):
    l, r, c, h = LI()
    lrch.append((l-1, r, c, h))
itox = defaultdict(list)

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

for i in itox:
    itox[i].sort(key=lambda x: -x[0])

p = round(k**0.5)
ans = [-1]*q
bit = [0]*(n+1)
pre = [0]*(n+1)
for ti, (l, r, c, h) in enumerate(lrch):
    add(l, h)
    add(r, -h)
    if ti%p == p-1 or ti == k-1:
        deli = []
        for i in itox.keys():
            s = cumsum(i)
            if s >= itox[i][-1][0]:
                x, qi = itox[i].pop()
                if not itox[i]: deli.append(i)
                for j in range(ti, -1, -1):
                    pl, pr, pc, ph = lrch[j]
                    if pl <= i < pr: s -= ph
                    if s < x:
                        ans[qi] = pc
                        break
        for i in deli: del itox[i]

for a in ans: print(a)
0