結果

問題 No.205 マージして辞書順最小
ユーザー qib
提出日時 2023-02-16 17:02:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 322 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 74,112 KB
最終ジャッジ日時 2024-07-18 17:14:20
合計ジャッジ時間 2,226 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n = int(input())

hp = []
for _ in range(n):
  si = input()
  heapq.heappush(hp, si + "~")

ans = []
while len(hp) > 0:
  cur = heapq.heappop(hp)
  if len(cur) == 1:
    continue
  elif len(hp) == 0:
    ans.append(cur[:-1])
  else:
    ans.append(cur[0])
    heapq.heappush(hp, cur[1:])

print("".join(ans))
0