結果

問題 No.205 マージして辞書順最小
ユーザー takakintakakin
提出日時 2020-06-21 23:32:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 329 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 8,316 KB
最終ジャッジ日時 2023-09-16 18:56:49
合計ジャッジ時間 1,638 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,292 KB
testcase_01 AC 17 ms
8,108 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 17 ms
8,264 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 19 ms
8,136 KB
testcase_11 AC 20 ms
8,160 KB
testcase_12 AC 20 ms
8,112 KB
testcase_13 AC 19 ms
8,260 KB
testcase_14 AC 16 ms
8,100 KB
testcase_15 AC 16 ms
8,180 KB
testcase_16 AC 17 ms
8,264 KB
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
S=[input() for _ in range(n)]
import heapq
H=[]
ans=""
C=[1]*n
M=[0]*n
for i in range(n):
  heapq.heappush(H,(S[i][0],i))
  M[i]=len(S[i])
while H:
  a,i=heapq.heappop(H)
  ans+=a
  if C[i]<M[i]:
    heapq.heappush(H,(S[i][C[i]],i))
    C[i]+=1
print(ans)
  
0