結果
問題 | No.2809 Sort Query |
ユーザー | hato336 |
提出日時 | 2024-07-12 23:13:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,795 ms / 2,000 ms |
コード長 | 4,227 bytes |
コンパイル時間 | 459 ms |
コンパイル使用メモリ | 82,352 KB |
実行使用メモリ | 289,416 KB |
最終ジャッジ日時 | 2024-07-12 23:14:58 |
合計ジャッジ時間 | 84,028 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 140 ms
88,948 KB |
testcase_01 | AC | 1,270 ms
261,180 KB |
testcase_02 | AC | 1,261 ms
261,260 KB |
testcase_03 | AC | 1,258 ms
260,852 KB |
testcase_04 | AC | 1,214 ms
260,956 KB |
testcase_05 | AC | 1,205 ms
261,212 KB |
testcase_06 | AC | 875 ms
191,232 KB |
testcase_07 | AC | 927 ms
191,300 KB |
testcase_08 | AC | 900 ms
191,396 KB |
testcase_09 | AC | 917 ms
191,384 KB |
testcase_10 | AC | 873 ms
190,964 KB |
testcase_11 | AC | 802 ms
231,484 KB |
testcase_12 | AC | 834 ms
231,384 KB |
testcase_13 | AC | 804 ms
230,288 KB |
testcase_14 | AC | 838 ms
230,328 KB |
testcase_15 | AC | 832 ms
231,332 KB |
testcase_16 | AC | 785 ms
231,260 KB |
testcase_17 | AC | 807 ms
231,232 KB |
testcase_18 | AC | 799 ms
231,020 KB |
testcase_19 | AC | 805 ms
230,076 KB |
testcase_20 | AC | 826 ms
229,708 KB |
testcase_21 | AC | 1,795 ms
287,076 KB |
testcase_22 | AC | 1,706 ms
288,864 KB |
testcase_23 | AC | 1,725 ms
288,784 KB |
testcase_24 | AC | 1,725 ms
289,416 KB |
testcase_25 | AC | 1,744 ms
286,352 KB |
testcase_26 | AC | 1,561 ms
267,376 KB |
testcase_27 | AC | 1,486 ms
267,636 KB |
testcase_28 | AC | 1,521 ms
267,044 KB |
testcase_29 | AC | 1,503 ms
266,920 KB |
testcase_30 | AC | 1,485 ms
267,080 KB |
testcase_31 | AC | 673 ms
201,732 KB |
testcase_32 | AC | 712 ms
202,768 KB |
testcase_33 | AC | 689 ms
201,672 KB |
testcase_34 | AC | 665 ms
202,512 KB |
testcase_35 | AC | 723 ms
202,364 KB |
testcase_36 | AC | 699 ms
237,276 KB |
testcase_37 | AC | 728 ms
237,332 KB |
testcase_38 | AC | 698 ms
237,004 KB |
testcase_39 | AC | 716 ms
237,284 KB |
testcase_40 | AC | 716 ms
236,988 KB |
testcase_41 | AC | 1,191 ms
239,808 KB |
testcase_42 | AC | 1,168 ms
240,636 KB |
testcase_43 | AC | 1,172 ms
239,756 KB |
testcase_44 | AC | 1,469 ms
240,412 KB |
testcase_45 | AC | 1,239 ms
240,188 KB |
testcase_46 | AC | 1,046 ms
237,292 KB |
testcase_47 | AC | 993 ms
237,516 KB |
testcase_48 | AC | 1,022 ms
237,280 KB |
testcase_49 | AC | 1,003 ms
237,504 KB |
testcase_50 | AC | 1,017 ms
237,292 KB |
testcase_51 | AC | 990 ms
237,180 KB |
testcase_52 | AC | 808 ms
237,108 KB |
testcase_53 | AC | 894 ms
237,212 KB |
testcase_54 | AC | 814 ms
237,508 KB |
testcase_55 | AC | 820 ms
237,280 KB |
testcase_56 | AC | 1,145 ms
236,488 KB |
testcase_57 | AC | 1,046 ms
197,212 KB |
testcase_58 | AC | 904 ms
171,740 KB |
testcase_59 | AC | 1,045 ms
217,816 KB |
testcase_60 | AC | 940 ms
247,680 KB |
testcase_61 | AC | 1,155 ms
265,192 KB |
testcase_62 | AC | 958 ms
207,512 KB |
testcase_63 | AC | 1,166 ms
260,492 KB |
testcase_64 | AC | 1,279 ms
250,288 KB |
testcase_65 | AC | 883 ms
222,812 KB |
testcase_66 | AC | 141 ms
89,184 KB |
testcase_67 | AC | 137 ms
89,100 KB |
testcase_68 | AC | 139 ms
88,944 KB |
testcase_69 | AC | 138 ms
89,268 KB |
testcase_70 | AC | 140 ms
89,076 KB |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline #n = int(input()) # #alist = [] #https://github.com/shakayami/ACL-for-python/blob/master/segtree.py class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<<self.log self.d=[E for i in range(2*self.size)] for i in range(self.n): self.d[self.size+i]=V[i] for i in range(self.size-1,0,-1): self.update(i) def set(self,p,x): assert 0<=p and p<self.n p+=self.size self.d[p]=x for i in range(1,self.log+1): self.update(p>>i) def get(self,p): assert 0<=p and p<self.n return self.d[p+self.size] def prod(self,l,r): assert 0<=l and l<=r and r<=self.n sml=self.e smr=self.e l+=self.size r+=self.size while(l<r): if (l&1): sml=self.op(sml,self.d[l]) l+=1 if (r&1): smr=self.op(self.d[r-1],smr) r-=1 l>>=1 r>>=1 return self.op(sml,smr) def all_prod(self): return self.d[1] def max_right(self,l,f): assert 0<=l and l<=self.n assert f(self.e) if l==self.n: return self.n l+=self.size sm=self.e while(1): while(l%2==0): l>>=1 if not(f(self.op(sm,self.d[l]))): while(l<self.size): l=2*l if f(self.op(sm,self.d[l])): sm=self.op(sm,self.d[l]) l+=1 return l-self.size sm=self.op(sm,self.d[l]) l+=1 if (l&-l)==l: break return self.n def min_left(self,r,f): assert 0<=r and r<=self.n assert f(self.e) if r==0: return 0 r+=self.size sm=self.e while(1): r-=1 while(r>1 and (r%2)): r>>=1 if not(f(self.op(self.d[r],sm))): while(r<self.size): r=(2*r+1) if f(self.op(self.d[r],sm)): sm=self.op(self.d[r],sm) r-=1 return r+1-self.size sm=self.op(self.d[r],sm) if (r& -r)==r: break return 0 def update(self,k): self.d[k]=self.op(self.d[2*k],self.d[2*k+1]) def __str__(self): return str([self.get(i) for i in range(self.n)]) input = sys.stdin.readline n,q = map(int,input().split()) a = list(map(int,input().split())) check = set([i for i in range(n)]) query = [] b = a[:] for i in range(q): t = list(map(int,input().split())) query.append(t) if t[0] == 1: b.append(t[2]) b = list(set(b)) b.sort() d = {b[i]:i for i in range(len(b))} st = segtree([0 for i in range(len(b))],operator.add,0) for i in a: st.set(d[i],st.get(d[i])+1) lazy = [] for i in range(q): t = query[i] if t[0] == 3: t,k,= t k -= 1 if k in check: print(a[k]) else: k += 1 def f(z): if z < k: return 1 else: return 0 y = st.max_right(0,f) print(b[y]) elif t[0] == 2: for x,y in lazy: st.set(d[y],st.get(d[y])-1) st.set(d[x],st.get(d[x])+1) #print(x,y) lazy.clear() check.clear() elif t[0] == 1: t,k,x = t if k-1 in check: z = a[k-1] else: def f(z): if z < k: return 1 else: return 0 y = st.max_right(0,f) z = b[y] lazy.append((x,z)) a[k-1] = x check.add(k-1)