結果

問題 No.205 マージして辞書順最小
ユーザー tentententen
提出日時 2020-10-07 12:01:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 3,092 ms
コンパイル使用メモリ 72,376 KB
実行使用メモリ 58,620 KB
最終ジャッジ日時 2023-09-27 09:13:23
合計ジャッジ時間 5,755 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,996 KB
testcase_01 AC 112 ms
56,112 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 114 ms
55,964 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 136 ms
56,468 KB
testcase_11 AC 138 ms
54,584 KB
testcase_12 WA -
testcase_13 AC 137 ms
55,868 KB
testcase_14 AC 116 ms
56,284 KB
testcase_15 AC 114 ms
54,276 KB
testcase_16 AC 113 ms
55,964 KB
testcase_17 AC 111 ms
53,704 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<StringBuilder> queue = new PriorityQueue<>();
		while (0 < n--) {
		    StringBuilder sb = new StringBuilder(sc.next());
		    sb.append('A');
		    queue.add(sb);
		}
		StringBuilder ans = new StringBuilder();
		while (queue.size() > 0) {
		    StringBuilder sb = queue.poll();
		    ans.append(sb.charAt(0));
		    sb.deleteCharAt(0);
		    if (sb.length() > 1) {
		        queue.add(sb);
		    }
		}
		System.out.println(ans);
	}
}
0