結果

問題 No.318 学学学学学
ユーザー ああいいああいい
提出日時 2022-01-07 11:17:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,328 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 106,836 KB
最終ジャッジ日時 2024-04-26 08:13:52
合計ジャッジ時間 18,529 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
80,048 KB
testcase_01 AC 324 ms
82,900 KB
testcase_02 AC 416 ms
83,560 KB
testcase_03 AC 303 ms
81,132 KB
testcase_04 AC 375 ms
83,968 KB
testcase_05 AC 1,328 ms
105,084 KB
testcase_06 AC 1,063 ms
106,640 KB
testcase_07 AC 890 ms
102,108 KB
testcase_08 AC 748 ms
98,944 KB
testcase_09 AC 644 ms
96,092 KB
testcase_10 AC 629 ms
94,848 KB
testcase_11 AC 1,237 ms
105,448 KB
testcase_12 AC 918 ms
106,836 KB
testcase_13 AC 820 ms
101,980 KB
testcase_14 AC 792 ms
98,944 KB
testcase_15 AC 715 ms
96,256 KB
testcase_16 AC 607 ms
94,916 KB
testcase_17 AC 951 ms
105,640 KB
testcase_18 AC 869 ms
105,984 KB
testcase_19 AC 971 ms
105,856 KB
testcase_20 AC 629 ms
93,308 KB
testcase_21 AC 37 ms
52,480 KB
testcase_22 AC 37 ms
52,608 KB
testcase_23 AC 41 ms
52,480 KB
testcase_24 AC 43 ms
52,532 KB
testcase_25 AC 41 ms
52,404 KB
testcase_26 AC 42 ms
52,224 KB
testcase_27 AC 41 ms
52,480 KB
testcase_28 AC 37 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
a = list(map(int,input().split()))

d = dict()
for i in range(N):
    if a[i] not in d:
        d[a[i]] = [i,-1]
    else:
        d[a[i]][1] = i

n = 1
while n < N:
    n <<= 1

dat = [0] * (2 * n - 1)
lazy = [0] * (2 * n -1)
def eval(k):
    if lazy[k] == 0:return
    if k < n - 1:
        lazy[k*2+1] = lazy[k]
        lazy[k*2+2] = lazy[k]
    dat[k] = lazy[k]
    lazy[k] = 0
def update(a,b,x,k=0,l=0,r=n):
    eval(k)
    if r <= a or b <= l:return
    if a <= l and r <= b:
        lazy[k] = x
        eval(k)
        return
    update(a,b,x,k*2+1,l,(l+r)//2)
    update(a,b,x,k*2+2,(l+r)//2,r)
    dat[k] = max(dat[k*2+1],dat[k*2+2])
def query(a,b,k=0,l=0,r=n):
    eval(k)
    if r <= a or b <= l:return 0
    if a <= l and r <= b:return dat[k]
    v1 = query(a,b,k*2+1,l,(l+r)//2)
    v2=query(a,b,k*2+2,(l+r)//2,r)
    return max(v1,v2)
l = sorted(d)
for i in l:
    l,r = d[i]
    if r == -1:
        update(l,l+1,i)
    else:
        update(l,r+1,i)
for i in range(N):
    b = query(i,i+1)
    if b == 0:
        b = a[i]
    print(b,end = " ")
print()
0