結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 22:34:19 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 5,000 ms |
| コード長 | 535 bytes |
| コンパイル時間 | 350 ms |
| コンパイル使用メモリ | 82,012 KB |
| 実行使用メモリ | 76,404 KB |
| 最終ジャッジ日時 | 2025-04-15 22:35:56 |
| 合計ジャッジ時間 | 2,025 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
import heapq
class PriorityString:
def __init__(self, s):
self.s = s
def __lt__(self, other):
return (self.s + other.s) < (other.s + self.s)
n = int(input())
strings = [input().strip() for _ in range(n)]
heap = []
for s in strings:
if s:
heapq.heappush(heap, PriorityString(s))
result = []
while heap:
current = heapq.heappop(heap)
result.append(current.s[0])
remaining = current.s[1:]
if remaining:
heapq.heappush(heap, PriorityString(remaining))
print(''.join(result))
lam6er