結果
問題 | No.2650 [Cherry 6th Tune *] セイジャク |
ユーザー | 👑 timi |
提出日時 | 2024-02-23 21:54:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,003 ms / 2,500 ms |
コード長 | 2,791 bytes |
コンパイル時間 | 556 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 99,436 KB |
最終ジャッジ日時 | 2024-02-23 21:55:55 |
合計ジャッジ時間 | 26,784 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,460 KB |
testcase_01 | AC | 43 ms
53,460 KB |
testcase_02 | AC | 446 ms
88,520 KB |
testcase_03 | AC | 266 ms
79,744 KB |
testcase_04 | AC | 657 ms
85,248 KB |
testcase_05 | AC | 574 ms
84,540 KB |
testcase_06 | AC | 389 ms
81,904 KB |
testcase_07 | AC | 544 ms
83,696 KB |
testcase_08 | AC | 351 ms
81,392 KB |
testcase_09 | AC | 948 ms
99,284 KB |
testcase_10 | AC | 992 ms
99,436 KB |
testcase_11 | AC | 1,003 ms
99,388 KB |
testcase_12 | AC | 997 ms
99,388 KB |
testcase_13 | AC | 963 ms
99,424 KB |
testcase_14 | AC | 961 ms
99,424 KB |
testcase_15 | AC | 976 ms
99,284 KB |
testcase_16 | AC | 864 ms
99,376 KB |
testcase_17 | AC | 904 ms
99,048 KB |
testcase_18 | AC | 874 ms
99,400 KB |
testcase_19 | AC | 932 ms
99,412 KB |
testcase_20 | AC | 907 ms
99,412 KB |
testcase_21 | AC | 904 ms
99,424 KB |
testcase_22 | AC | 879 ms
99,412 KB |
testcase_23 | AC | 778 ms
99,412 KB |
testcase_24 | AC | 753 ms
99,424 KB |
testcase_25 | AC | 759 ms
99,296 KB |
testcase_26 | AC | 728 ms
99,436 KB |
testcase_27 | AC | 778 ms
99,436 KB |
testcase_28 | AC | 749 ms
99,388 KB |
testcase_29 | AC | 826 ms
99,388 KB |
testcase_30 | AC | 588 ms
99,436 KB |
testcase_31 | AC | 768 ms
99,436 KB |
testcase_32 | AC | 544 ms
99,436 KB |
ソースコード
# T=int(input()) # for i in range(T): N,A=map(int,input().split()) #N=int(input()) X=list(map(int, input().split())) C=[] for i in range(N): C.append((X[i],i)) C=sorted(C) D=sorted(X) #print(C,D) import bisect import sys class Lazysegtree: def __init__(self, A, intv, initialize = True): #区間は 1-indexed で管理 self.N = len(A) self.N0 = 2**(self.N-1).bit_length() self.intv = intv #self.segf = segf self.lazy = [None]*(2*self.N0) if initialize: self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N) for i in range(self.N0-2, -1, -1): self.data[i] = min(self.data[2*i], self.data[2*i+1]) else: self.data = [intv]*(2*self.N0) def _ascend(self, k): k = k >> 1 c = k.bit_length() for j in range(c): idx = k >> j self.data[idx] = min(self.data[2*idx], self.data[2*idx+1]) def _descend(self, k): k = k >> 1 idx = 1 c = k.bit_length() for j in range(1, c+1): idx = k >> (c - j) if self.lazy[idx] is None: continue self.data[2*idx] = self.data[2*idx+1] = self.lazy[2*idx] \ = self.lazy[2*idx+1] = self.lazy[idx] self.lazy[idx] = None def query(self, l, r): L = l+self.N0 R = r+self.N0 self._descend(L//(L & -L)) self._descend(R//(R & -R) - 1) s = self.intv while L < R: if R & 1: R -= 1 s = min(s, self.data[R]) if L & 1: s = min(s, self.data[L]) L += 1 L >>= 1 R >>= 1 return s def update(self, l, r, x): L = l+self.N0 R = r+self.N0 Li = L//(L & -L) Ri = R//(R & -R) self._descend(Li) self._descend(Ri-1) while L < R : if R & 1: R -= 1 self.data[R] = x self.lazy[R] = x if L & 1: self.data[L] = x self.lazy[L] = x L += 1 L >>= 1 R >>= 1 self._ascend(Li) self._ascend(Ri-1) T = Lazysegtree([0]*(N+10), 2**31-1, initialize = False) Q=int(input()) for i in range(Q): l,r=map(int,input().split()) ll,rr=bisect.bisect_left(D,l),bisect.bisect_right(D,r) T.update(ll,rr,i+2) E=[] for i in range(N): E.append(T.query(i,i+1)) ans=[-1]*N;now=0 for _,x in C: e=E[now] now+=1 if e!=2147483647: ans[x]=e-1 for i in ans: print(i)