結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-22 01:37:56
言語 Java19
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,046 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 74,220 KB
実行使用メモリ 63,792 KB
最終ジャッジ日時 2023-09-18 07:37:06
合計ジャッジ時間 6,051 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 811 ms
62,312 KB
testcase_01 AC 810 ms
62,668 KB
testcase_02 RE -
testcase_03 AC 794 ms
63,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int n = koko.nextInt();
        for(int m=0; m<n; m++){
            int t = koko.nextInt();
            int[] l = new int[t];
            int[] count = new int[t];
            for(int i=0; i<t; i++){
                l[i]=koko.nextInt();
            }
            Arrays.sort(l);
            int kind = 0;
            int cou = 1;
            for(int i=1; i<t; i++){
                if(l[i]==l[i-1]){
                    cou++;
                }else{
                    count[kind++]=cou;
                    cou=1;
                }
            }
            count[kind++]=cou;
            Arrays.sort(count);
            int kumi=0;
            while(count[t-3]>0){
                kumi++;
                count[t-3]--;
                count[t-2]--;
                count[t-1]--;
                Arrays.sort(count);
            }
            System.out.println(kumi);
        }
    }
}
0