結果

問題 No.205 マージして辞書順最小
ユーザー nebukuro09nebukuro09
提出日時 2016-10-27 11:01:08
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 318 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 6,608 KB
実行使用メモリ 6,364 KB
最終ジャッジ日時 2023-08-15 19:35:23
合計ジャッジ時間 1,288 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,312 KB
testcase_01 AC 12 ms
6,324 KB
testcase_02 AC 12 ms
6,312 KB
testcase_03 AC 13 ms
6,252 KB
testcase_04 AC 11 ms
6,224 KB
testcase_05 AC 12 ms
6,300 KB
testcase_06 AC 10 ms
6,336 KB
testcase_07 AC 13 ms
6,256 KB
testcase_08 AC 12 ms
6,312 KB
testcase_09 AC 13 ms
6,252 KB
testcase_10 AC 12 ms
6,364 KB
testcase_11 AC 13 ms
6,148 KB
testcase_12 AC 13 ms
6,196 KB
testcase_13 AC 13 ms
6,280 KB
testcase_14 AC 10 ms
6,196 KB
testcase_15 AC 10 ms
6,316 KB
testcase_16 AC 10 ms
6,272 KB
testcase_17 AC 10 ms
6,288 KB
testcase_18 AC 10 ms
6,200 KB
権限があれば一括ダウンロードができます

ソースコード

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