結果
| 問題 |
No.1982 [Cherry 4th Tune B] 絶険
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-17 18:03:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,622 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 82,204 KB |
| 実行使用メモリ | 150,560 KB |
| 最終ジャッジ日時 | 2024-06-29 19:24:36 |
| 合計ジャッジ時間 | 22,370 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 WA * 13 |
ソースコード
#BIT plus ver
class BITplus:
def __init__(self,N):
self.N = N
self.bit = [0] * (self.N+1)
def add(self,i,x):
while i <= self.N:
self.bit[i] += x
i += i & -i
def fold(self,i):
ans = 0
while i > 0:
ans += self.bit[i]
i -= i & -i
return ans
def lb(self,w):
if w <= 0:return 0
x = 0
k = 1
while k <= self.N:
k <<= 1
k >>= 1
while k:
if x + k <= self.N and self.bit[x+k] < w:
w -= self.bit[x+k]
x += k
k >>= 1
return x + 1
#サイズ N の配列をいれる
def build(self,seq):
bit = self.bit
N = self.N
for i in range(N):
bit[i+1] = seq[i]
for i in range(1,N+1):
if i + (i & -1) <= N:
bit[i + (i & -i)] += bit[i]
import sys
rr = sys.stdin
N,K,Q = map(int,rr.readline().split())
sousa = [[] for _ in range(N + 2)]
col = []
for _ in range(K):
l,r,c,h = map(int,rr.readline().split())
sousa[l].append((_,h))
sousa[r + 1].append((_,-h))
col.append(c)
bit = BITplus(Q + 1)
query = []
for _ in range(Q):
i,x = map(int,input().split())
query.append((i,x,_))
query.sort(key = lambda x:x[0])
ans = [0] * Q
now = 0
for i,x,_ in query:
while now <= i:
for q,d in sousa[now]:
bit.add(q + 1,d)
now += 1
tmp = bit.fold(Q + 1)
#print(tmp)
if tmp < x:
ans[_] = -1
continue
t = bit.lb(x)
ans[_] = col[t - 1]
print(*ans,sep = "\n")