結果

問題 No.205 マージして辞書順最小
ユーザー qibqib
提出日時 2023-02-16 17:02:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 322 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 77,664 KB
最終ジャッジ日時 2023-09-25 21:28:50
合計ジャッジ時間 4,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,512 KB
testcase_01 AC 76 ms
71,520 KB
testcase_02 AC 94 ms
76,380 KB
testcase_03 AC 95 ms
76,028 KB
testcase_04 AC 94 ms
75,824 KB
testcase_05 AC 89 ms
76,000 KB
testcase_06 AC 74 ms
71,124 KB
testcase_07 AC 101 ms
77,452 KB
testcase_08 AC 95 ms
76,244 KB
testcase_09 AC 95 ms
76,568 KB
testcase_10 AC 103 ms
77,520 KB
testcase_11 AC 106 ms
77,664 KB
testcase_12 AC 109 ms
77,536 KB
testcase_13 AC 100 ms
77,380 KB
testcase_14 AC 74 ms
71,412 KB
testcase_15 AC 73 ms
71,188 KB
testcase_16 AC 71 ms
71,516 KB
testcase_17 AC 72 ms
71,100 KB
testcase_18 AC 73 ms
71,404 KB
権限があれば一括ダウンロードができます

ソースコード

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