結果
問題 | No.205 マージして辞書順最小 |
ユーザー |
|
提出日時 | 2023-03-27 01:17:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 120 ms / 5,000 ms |
コード長 | 561 bytes |
コンパイル時間 | 272 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 78,720 KB |
最終ジャッジ日時 | 2024-09-19 10:04:50 |
合計ジャッジ時間 | 3,000 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
# https://yukicoder.me/problems/no/205 from heapq import heapify, heappop, heappush from typing import List def minLexMerge(words: List[str]) -> str: """字典序最小的合并字符串""" pq = [w + chr(130) for w in words] heapify(pq) res = [] while pq: min_ = heappop(pq) res.append(min_[0]) min_ = min_[1:] if len(min_) >= 2: heappush(pq, min_) return "".join(res) if __name__ == "__main__": N = int(input()) words = [input() for _ in range(N)] print(minLexMerge(words))