結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー kou6839kou6839
提出日時 2015-01-14 00:59:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 909 bytes
コンパイル時間 2,345 ms
コンパイル使用メモリ 75,376 KB
実行使用メモリ 74,212 KB
最終ジャッジ日時 2023-09-04 12:46:49
合計ジャッジ時間 7,102 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import java.math.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t= sc.nextInt();
        for(int i=0;i<t;i++){
        	int n = sc.nextInt();
        	HashMap<Integer,Integer> matu = new HashMap<>();
        	for(int j=0;j<n;j++){
        		int a = sc.nextInt();
        		if(!matu.containsKey(a)) matu.put(a, 0);
        		matu.put(a, matu.get(a)+1);
        	}
        	int ans=0;
        	tt:while(true){
        		if(matu.size()<3) break;
        		ans++;
        		int count=1;
        		for(int b:matu.keySet()){
        			matu.put(b, matu.get(b)-1);
        			if(count==3) break;
        			count++;
        		}
        		Object[] aaa = matu.keySet().toArray();
        		for(Object aa:aaa){
        			if(matu.get(aa)==0) matu.remove(aa);
        		}
        	}
        	System.out.println(ans);
        }
	}
}
0