結果

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

ソースコード

diff #

import heapq
N = int(raw_input())
S = [raw_input() + "{" for i in xrange(N)]
M = sum(map(len, S)) - N
heapq.heapify(S)
T = ""

for i in xrange(M):
    s = heapq.heappop(S)
    if s == "": continue
    T += s[0]
    heapq.heappush(S, s[1:])
print T
0