結果

問題 No.205 マージして辞書順最小
ユーザー ぴろずぴろず
提出日時 2015-05-08 22:41:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 547 bytes
コンパイル時間 2,739 ms
コンパイル使用メモリ 76,792 KB
実行使用メモリ 56,076 KB
最終ジャッジ日時 2023-09-19 06:57:01
合計ジャッジ時間 6,711 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
55,564 KB
testcase_01 AC 128 ms
55,680 KB
testcase_02 AC 143 ms
55,756 KB
testcase_03 AC 146 ms
55,616 KB
testcase_04 AC 145 ms
55,868 KB
testcase_05 AC 142 ms
55,940 KB
testcase_06 AC 128 ms
55,792 KB
testcase_07 AC 150 ms
55,684 KB
testcase_08 AC 148 ms
56,076 KB
testcase_09 AC 147 ms
55,448 KB
testcase_10 AC 152 ms
55,632 KB
testcase_11 AC 150 ms
55,884 KB
testcase_12 AC 153 ms
55,892 KB
testcase_13 AC 148 ms
56,000 KB
testcase_14 AC 133 ms
55,464 KB
testcase_15 AC 133 ms
55,476 KB
testcase_16 AC 130 ms
55,752 KB
testcase_17 AC 129 ms
55,312 KB
testcase_18 AC 129 ms
55,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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());
	}

}
0