結果

問題 No.318 学学学学学
ユーザー rpy3cpprpy3cpp
提出日時 2015-12-11 01:38:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 425 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 35,308 KB
最終ジャッジ日時 2023-09-04 17:06:57
合計ジャッジ時間 6,513 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
9,996 KB
testcase_01 AC 63 ms
12,356 KB
testcase_02 AC 75 ms
13,072 KB
testcase_03 AC 55 ms
11,732 KB
testcase_04 AC 66 ms
12,724 KB
testcase_05 AC 425 ms
35,308 KB
testcase_06 AC 369 ms
30,312 KB
testcase_07 AC 327 ms
25,792 KB
testcase_08 AC 247 ms
22,792 KB
testcase_09 AC 181 ms
20,748 KB
testcase_10 AC 145 ms
19,388 KB
testcase_11 AC 408 ms
35,164 KB
testcase_12 AC 274 ms
28,532 KB
testcase_13 AC 223 ms
24,444 KB
testcase_14 AC 189 ms
21,768 KB
testcase_15 AC 164 ms
20,564 KB
testcase_16 AC 141 ms
19,284 KB
testcase_17 AC 262 ms
29,120 KB
testcase_18 AC 239 ms
28,160 KB
testcase_19 AC 207 ms
30,620 KB
testcase_20 AC 138 ms
18,268 KB
testcase_21 AC 16 ms
8,332 KB
testcase_22 AC 16 ms
8,320 KB
testcase_23 AC 17 ms
8,000 KB
testcase_24 AC 17 ms
7,944 KB
testcase_25 AC 16 ms
8,024 KB
testcase_26 AC 17 ms
8,024 KB
testcase_27 AC 16 ms
7,996 KB
testcase_28 AC 17 ms
8,168 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 and c == -pq[0]:
        while pq and dic[-pq[0]][1] <= i: heapq.heappop(pq)
print(*Bs)
0