結果

問題 No.318 学学学学学
ユーザー H3PO4H3PO4
提出日時 2020-11-29 14:06:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 100,808 KB
最終ジャッジ日時 2023-10-11 02:26:11
合計ジャッジ時間 10,049 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
78,856 KB
testcase_01 AC 178 ms
80,732 KB
testcase_02 AC 197 ms
82,404 KB
testcase_03 AC 168 ms
80,148 KB
testcase_04 AC 178 ms
81,392 KB
testcase_05 AC 318 ms
97,676 KB
testcase_06 AC 254 ms
94,088 KB
testcase_07 AC 249 ms
94,136 KB
testcase_08 AC 238 ms
94,088 KB
testcase_09 AC 220 ms
94,136 KB
testcase_10 AC 193 ms
94,044 KB
testcase_11 AC 321 ms
97,684 KB
testcase_12 AC 310 ms
94,112 KB
testcase_13 AC 288 ms
93,924 KB
testcase_14 AC 257 ms
94,160 KB
testcase_15 AC 242 ms
93,972 KB
testcase_16 AC 217 ms
93,868 KB
testcase_17 AC 244 ms
100,540 KB
testcase_18 AC 230 ms
96,144 KB
testcase_19 AC 170 ms
100,808 KB
testcase_20 AC 205 ms
93,212 KB
testcase_21 AC 78 ms
71,648 KB
testcase_22 AC 77 ms
71,296 KB
testcase_23 AC 77 ms
71,388 KB
testcase_24 AC 77 ms
71,432 KB
testcase_25 AC 78 ms
71,484 KB
testcase_26 AC 77 ms
71,316 KB
testcase_27 AC 77 ms
71,360 KB
testcase_28 AC 77 ms
71,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq


class Set_min(set):
    def __init__(self, iterable=tuple()):
        super(Set_min, self).__init__(iterable)
        self.h = list(iterable)
        heapq.heapify(self.h)

    def add(self, x):
        super(Set_min, self).add(x)
        heapq.heappush(self.h, x)

    def remove(self, x):
        super(Set_min, self).remove(x)

    def min(self):
        if not super(Set_min, self).__len__():
            raise ValueError
        while self.h and self.h[0] not in self:
            heapq.heappop(self.h)
        return self.h[0]


N = int(input())
A = tuple(map(int, input().split()))

R = dict()
for i, a in enumerate(A):
    R[a] = i

st = Set_min()
ans = [0] * N
for i, a in enumerate(A):
    st.add(-a)
    ans[i] = -st.min()
    if R[a] == i:
        st.remove(-a)
print(*ans)
0