結果
問題 | No.205 マージして辞書順最小 |
ユーザー |
![]() |
提出日時 | 2015-05-08 22:41:43 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 161 ms / 5,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 2,201 ms |
コンパイル使用メモリ | 78,216 KB |
実行使用メモリ | 41,620 KB |
最終ジャッジ日時 | 2024-07-05 19:03:16 |
合計ジャッジ時間 | 5,600 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
package no205; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); PriorityQueue<String> pq = new PriorityQueue<>(); for(int i=0;i<n;i++) { pq.add(sc.next() + "{"); } StringBuilder ans = new StringBuilder(); while(!pq.isEmpty()) { String min = pq.poll(); ans.append(min.charAt(0)); if (min.length() > 2) { pq.offer(min.substring(1)); } } System.out.println(ans.toString()); } }