結果
問題 | No.2650 [Cherry 6th Tune *] セイジャク |
ユーザー | Akijin_007 |
提出日時 | 2024-02-23 21:58:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,421 ms / 2,500 ms |
コード長 | 2,647 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 175,072 KB |
最終ジャッジ日時 | 2024-09-30 13:43:12 |
合計ジャッジ時間 | 36,518 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
52,224 KB |
testcase_01 | AC | 41 ms
52,480 KB |
testcase_02 | AC | 435 ms
108,468 KB |
testcase_03 | AC | 346 ms
92,672 KB |
testcase_04 | AC | 1,045 ms
175,072 KB |
testcase_05 | AC | 853 ms
151,408 KB |
testcase_06 | AC | 500 ms
113,280 KB |
testcase_07 | AC | 907 ms
157,772 KB |
testcase_08 | AC | 410 ms
102,400 KB |
testcase_09 | AC | 1,421 ms
163,160 KB |
testcase_10 | AC | 1,402 ms
162,288 KB |
testcase_11 | AC | 1,421 ms
161,392 KB |
testcase_12 | AC | 1,411 ms
161,820 KB |
testcase_13 | AC | 1,406 ms
162,124 KB |
testcase_14 | AC | 1,392 ms
162,124 KB |
testcase_15 | AC | 1,384 ms
159,560 KB |
testcase_16 | AC | 1,142 ms
161,044 KB |
testcase_17 | AC | 1,118 ms
169,056 KB |
testcase_18 | AC | 1,079 ms
162,236 KB |
testcase_19 | AC | 1,145 ms
162,792 KB |
testcase_20 | AC | 1,143 ms
162,336 KB |
testcase_21 | AC | 1,170 ms
161,928 KB |
testcase_22 | AC | 1,175 ms
162,044 KB |
testcase_23 | AC | 1,080 ms
160,304 KB |
testcase_24 | AC | 1,094 ms
160,320 KB |
testcase_25 | AC | 1,017 ms
160,720 KB |
testcase_26 | AC | 1,049 ms
159,240 KB |
testcase_27 | AC | 1,095 ms
159,108 KB |
testcase_28 | AC | 1,029 ms
160,496 KB |
testcase_29 | AC | 1,095 ms
160,584 KB |
testcase_30 | AC | 1,031 ms
161,356 KB |
testcase_31 | AC | 1,219 ms
162,512 KB |
testcase_32 | AC | 546 ms
117,096 KB |
ソースコード
#int(input()) #map(int, input().split()) #list(map(int, input().split())) #区間更新用 def segfunc(x,y): return max(x,y) class LazySegTree_RUQ: def __init__(self,init_val,segfunc,ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1<<(n-1).bit_length() self.tree = [ide_ele]*2*self.num self.lazy = [None]*2*self.num for i in range(n): self.tree[self.num+i] = init_val[i] for i in range(self.num-1,0,-1): self.tree[i] = self.segfunc(self.tree[2*i],self.tree[2*i+1]) def gindex(self,l,r): l += self.num r += self.num lm = l>>(l&-l).bit_length() rm = r>>(r&-r).bit_length() while r>l: if l<=lm: yield l if r<=rm: yield r r >>= 1 l >>= 1 while l: yield l l >>= 1 def propagates(self,*ids): for i in reversed(ids): v = self.lazy[i] if v is None: continue self.lazy[i] = None self.lazy[2*i] = v self.lazy[2*i+1] = v self.tree[2*i] = v self.tree[2*i+1] = v def update(self,l,r,x): ids = self.gindex(l,r) self.propagates(*self.gindex(l,r)) l += self.num r += self.num while l<r: if l&1: self.lazy[l] = x self.tree[l] = x l += 1 if r&1: self.lazy[r-1] = x self.tree[r-1] = x r >>= 1 l >>= 1 for i in ids: self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1]) def query(self,l,r): ids = self.gindex(l,r) self.propagates(*self.gindex(l,r)) res = self.ide_ele l += self.num r += self.num while l<r: if l&1: res = self.segfunc(res,self.tree[l]) l += 1 if r&1: res = self.segfunc(res,self.tree[r-1]) l >>= 1 r >>= 1 return res N, A = map(int, input().split()) X = list(map(int, input().split())) T = int(input()) l = [0] * T for i in range(T): l[i] = list(map(int, input().split())) x = set(X) for i in range(T): x.add(l[i][0]) x.add(l[i][1]) x = sorted(x) ll = len(x) d = dict() for i in range(ll): d[x[i]] = i s = LazySegTree_RUQ([-1] * ll, segfunc, -1) for i in range(T): L, R = l[i] s.update(d[L], d[R]+1, i+1) for i in range(N): print(s.query(d[X[i]], d[X[i]]+1))