結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2019-12-30 17:32:08 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 797 bytes |
| コンパイル時間 | 2,520 ms |
| コンパイル使用メモリ | 81,412 KB |
| 実行使用メモリ | 48,996 KB |
| 最終ジャッジ日時 | 2024-11-08 20:32:51 |
| 合計ジャッジ時間 | 6,618 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
StringBuilder sb = new StringBuilder();
for (int j = 0; j < t; j++) {
int n = sc.nextInt();
HashMap<Integer, Integer> map = new HashMap<>();
int max = 1;
for (int i= 0; i < n; i++) {
int x = sc.nextInt();
if (map.containsKey(x)) {
map.put(x, map.get(x) + 1);
max = Math.max(max, map.get(x));
} else {
map.put(x, 1);
}
}
sb.append(Math.min(n / 3, (n - max) / 2)).append("\n");
}
System.out.print(sb);
}
}
htensai