結果

問題 No.205 マージして辞書順最小
ユーザー nebukuro09
提出日時 2016-10-27 11:01:08
言語 Python2
(2.7.18)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 318 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-11-24 04:02:07
合計ジャッジ時間 1,045 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

N = input()
S = [raw_input() for _ in xrange(N)]
maxlen = max(map(len, S)) + 1
q = []
for i in xrange(N):
    heapq.heappush(q, S[i]+'{'*(maxlen-len(S[i])+1))

ans = ''
while len(q) > 0:
    s = heapq.heappop(q)
    if s[0] == '{':
        continue
    ans += s[0]
    heapq.heappush(q, s[1:])
print ans
0