結果

問題 No.318 学学学学学
ユーザー rpy3cpprpy3cpp
提出日時 2015-12-11 01:23:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 414 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 35,436 KB
最終ジャッジ日時 2023-09-04 17:05:39
合計ジャッジ時間 7,065 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
10,052 KB
testcase_01 AC 63 ms
12,520 KB
testcase_02 AC 73 ms
13,076 KB
testcase_03 AC 53 ms
11,900 KB
testcase_04 AC 66 ms
12,588 KB
testcase_05 AC 414 ms
35,436 KB
testcase_06 AC 360 ms
30,288 KB
testcase_07 AC 293 ms
26,004 KB
testcase_08 AC 233 ms
22,500 KB
testcase_09 AC 183 ms
20,824 KB
testcase_10 AC 145 ms
19,344 KB
testcase_11 AC 392 ms
35,140 KB
testcase_12 AC 276 ms
28,580 KB
testcase_13 AC 222 ms
24,356 KB
testcase_14 AC 192 ms
21,716 KB
testcase_15 AC 168 ms
20,520 KB
testcase_16 AC 144 ms
19,104 KB
testcase_17 AC 260 ms
28,708 KB
testcase_18 AC 238 ms
28,008 KB
testcase_19 AC 208 ms
30,316 KB
testcase_20 AC 136 ms
18,108 KB
testcase_21 AC 17 ms
8,024 KB
testcase_22 AC 17 ms
8,040 KB
testcase_23 AC 17 ms
7,988 KB
testcase_24 AC 16 ms
8,028 KB
testcase_25 AC 17 ms
8,172 KB
testcase_26 AC 16 ms
8,136 KB
testcase_27 AC 17 ms
8,140 KB
testcase_28 AC 16 ms
8,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n = int(input())
As = list(map(int, input().split()))

dic = dict()
for i, a in enumerate(As):
    if a in dic:
        dic[a][1] = i
    else:
        dic[a] = [i, i]

Cs = [0] * n
for a, pair in dic.items():
    Cs[pair[0]] = a
    Cs[pair[1]] = a

Bs = []
pq = []
for i, c in enumerate(Cs):
    if c == 0:
        Bs.append(-pq[0])
        continue
    if dic[c][0] == i:
        heapq.heappush(pq, -c)
    Bs.append(-pq[0])
    if i == n - 1:
        break
    if dic[c][1] == i:
        if c == -pq[0]:
            while pq and dic[-pq[0]][1] <= i:
                heapq.heappop(pq)

print(*Bs)
0