結果
問題 |
No.2757 Pin Game
|
ユーザー |
|
提出日時 | 2024-05-24 00:01:32 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 891 bytes |
コンパイル時間 | 2,558 ms |
コンパイル使用メモリ | 88,056 KB |
実行使用メモリ | 95,416 KB |
最終ジャッジ日時 | 2024-12-20 19:09:08 |
合計ジャッジ時間 | 9,749 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | AC * 1 WA * 9 |
ソースコード
// 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()); } }