結果
問題 |
No.1982 [Cherry 4th Tune B] 絶険
|
ユーザー |
![]() |
提出日時 | 2022-06-17 23:06:40 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,930 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 171,456 KB |
最終ジャッジ日時 | 2024-10-09 09:30:36 |
合計ジャッジ時間 | 13,965 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 TLE * 2 -- * 28 |
ソースコード
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)