結果
| 問題 |
No.2707 Bag of Words Encryption
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-23 23:02:26 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 890 bytes |
| コンパイル時間 | 2,551 ms |
| コンパイル使用メモリ | 80,828 KB |
| 実行使用メモリ | 56,428 KB |
| 最終ジャッジ日時 | 2024-12-20 19:06:40 |
| 合計ジャッジ時間 | 7,042 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 2 |
| other | RE * 15 |
ソースコード
// No.2707 Bag of Words Encryption
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Map<String, Integer> wordCount = new HashMap<>();
for (int i = 0; i < n; i++) {
String word = sc.next();
wordCount.put(word, wordCount.getOrDefault(word, 0) + 1);
}
List<String> words = new ArrayList<>(wordCount.keySet());
words.sort(Comparator.comparingInt(wordCount::get));
StringBuilder encrypted = new StringBuilder();
for (String word : words) {
int count = wordCount.get(word);
for (int j = 0; j < count; j++) {
encrypted.append(word);
encrypted.append(" ");
}
}
System.out.println(encrypted.toString().trim());
}
}