結果
問題 | No.1982 [Cherry 4th Tune B] 絶険 |
ユーザー | tassei903 |
提出日時 | 2022-06-18 16:22:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,669 ms / 3,000 ms |
コード長 | 2,114 bytes |
コンパイル時間 | 428 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 194,464 KB |
最終ジャッジ日時 | 2024-06-08 17:38:02 |
合計ジャッジ時間 | 46,385 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,224 KB |
testcase_01 | AC | 37 ms
52,352 KB |
testcase_02 | AC | 38 ms
52,224 KB |
testcase_03 | AC | 805 ms
116,992 KB |
testcase_04 | AC | 1,123 ms
134,572 KB |
testcase_05 | AC | 1,055 ms
126,360 KB |
testcase_06 | AC | 1,380 ms
137,972 KB |
testcase_07 | AC | 1,566 ms
153,736 KB |
testcase_08 | AC | 1,004 ms
131,712 KB |
testcase_09 | AC | 1,143 ms
135,740 KB |
testcase_10 | AC | 1,354 ms
144,068 KB |
testcase_11 | AC | 855 ms
117,744 KB |
testcase_12 | AC | 1,527 ms
146,116 KB |
testcase_13 | AC | 868 ms
121,836 KB |
testcase_14 | AC | 1,330 ms
142,884 KB |
testcase_15 | AC | 928 ms
121,388 KB |
testcase_16 | AC | 1,146 ms
134,672 KB |
testcase_17 | AC | 2,241 ms
178,888 KB |
testcase_18 | AC | 1,675 ms
163,372 KB |
testcase_19 | AC | 2,006 ms
175,904 KB |
testcase_20 | AC | 309 ms
91,044 KB |
testcase_21 | AC | 468 ms
99,108 KB |
testcase_22 | AC | 1,058 ms
132,956 KB |
testcase_23 | AC | 445 ms
98,204 KB |
testcase_24 | AC | 881 ms
120,300 KB |
testcase_25 | AC | 1,983 ms
176,892 KB |
testcase_26 | AC | 1,867 ms
168,776 KB |
testcase_27 | AC | 417 ms
96,512 KB |
testcase_28 | AC | 678 ms
115,784 KB |
testcase_29 | AC | 1,263 ms
187,848 KB |
testcase_30 | AC | 738 ms
179,824 KB |
testcase_31 | AC | 723 ms
118,112 KB |
testcase_32 | AC | 2,669 ms
192,396 KB |
testcase_33 | AC | 1,948 ms
193,936 KB |
testcase_34 | AC | 1,976 ms
194,464 KB |
ソースコード
import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ######################################################################## Binary Indexed Tree (Fenwick Tree) # 0-indexed class BIT: def __init__(self, n): self.n = n self.data = [0]*(n+1) self.el = [0]*(n+1) def sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add(self, i, x): assert 0 <= i < self.n i = i+1 self.el[i] += x while i <= self.n: self.data[i] += x i += i & -i def set(self, i, x): assert 0 <= i <= self.n self.add(i,x-self.get(i)) def get(self, i, j=None):# j=Noneのときiを取得, [i, j)の和を取得 if j is None: return self.el[i+1] return self.sum(j) - self.sum(i) def lower_bound(self, k):# a[0],…,a[i]>kなる最小のi n = self.n x = 0 r = 1 while r <= n:r <<= 1 size = r while size: if x + size <= n and self.data[x+size] <= k: k-=self.data[x+size] x += size size >>= 1 return x def debug(self): res = [] n = self.n for i in range(n): res.append(self.get(i)) print(*res) N,K,Q = na() eve = [] color = [-1]*K for i in range(K): l,r,c,h = na() color[i] = c eve.append((l, 0, i, h)) eve.append((r, 2, i, h)) ans = [-1]*Q for j in range(Q): i, x = na() eve.append((i, 1, j, x-1)) eve = sorted(eve) bit = BIT(K) for i, p, j, h in eve: if p == 0: bit.add(j, h) elif p == 2: bit.add(j, -h) else: x = bit.lower_bound(h) #bit.debug() #print(x) if x == K: ans[j] = -1 else: ans[j] = color[x] print(*ans,sep="\n")