結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー htensaihtensai
提出日時 2019-12-30 17:32:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 797 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 74,268 KB
実行使用メモリ 61,388 KB
最終ジャッジ日時 2023-08-08 14:50:12
合計ジャッジ時間 6,006 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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