結果
問題 | No.318 学学学学学 |
ユーザー | titia |
提出日時 | 2023-01-01 00:18:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 257 ms / 2,000 ms |
コード長 | 1,035 bytes |
コンパイル時間 | 259 ms |
コンパイル使用メモリ | 87,144 KB |
実行使用メモリ | 116,980 KB |
最終ジャッジ日時 | 2023-08-17 22:56:28 |
合計ジャッジ時間 | 8,998 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 108 ms
78,488 KB |
testcase_01 | AC | 116 ms
84,176 KB |
testcase_02 | AC | 122 ms
86,712 KB |
testcase_03 | AC | 110 ms
82,324 KB |
testcase_04 | AC | 119 ms
85,360 KB |
testcase_05 | AC | 247 ms
116,816 KB |
testcase_06 | AC | 250 ms
100,920 KB |
testcase_07 | AC | 221 ms
99,584 KB |
testcase_08 | AC | 206 ms
97,908 KB |
testcase_09 | AC | 192 ms
94,988 KB |
testcase_10 | AC | 163 ms
95,328 KB |
testcase_11 | AC | 257 ms
116,980 KB |
testcase_12 | AC | 224 ms
104,000 KB |
testcase_13 | AC | 197 ms
95,400 KB |
testcase_14 | AC | 190 ms
94,592 KB |
testcase_15 | AC | 187 ms
94,024 KB |
testcase_16 | AC | 157 ms
95,480 KB |
testcase_17 | AC | 180 ms
108,160 KB |
testcase_18 | AC | 181 ms
103,348 KB |
testcase_19 | AC | 189 ms
108,160 KB |
testcase_20 | AC | 155 ms
93,360 KB |
testcase_21 | AC | 70 ms
71,172 KB |
testcase_22 | AC | 70 ms
71,220 KB |
testcase_23 | AC | 70 ms
71,208 KB |
testcase_24 | AC | 72 ms
71,436 KB |
testcase_25 | AC | 70 ms
71,048 KB |
testcase_26 | AC | 70 ms
71,476 KB |
testcase_27 | AC | 74 ms
71,420 KB |
testcase_28 | AC | 73 ms
71,380 KB |
ソースコード
n=int(input()) A=list(map(int,input().split())) seg_el=1<<((n+1).bit_length()) # Segment treeの台の要素数 SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 def getvalue(n,seg_el): # 一点の値を取得 i=n+seg_el ANS=0 ANS=max(SEG[i],ANS) i>>=1# 子ノードへ while i!=0: ANS=max(SEG[i],ANS) i>>=1 return ANS def updates(l,r,x): # 区間[l,r)のmaxを更新. L=l+seg_el R=r+seg_el while L<R: if L & 1: SEG[L]=max(x,SEG[L]) L+=1 if R & 1: R-=1 SEG[R]=max(x,SEG[R]) L>>=1 R>>=1 LEFT=dict() RIGHT=dict() for i in range(n): a=A[i] if a in LEFT: LEFT[a]=min(LEFT[a],i) else: LEFT[a]=i if a in RIGHT: RIGHT[a]=max(RIGHT[a],i) else: RIGHT[a]=i S=sorted(set(sorted(A))) for s in S: l=LEFT[s] r=RIGHT[s] updates(l,r+1,s) print(*[getvalue(i,seg_el) for i in range(n)])