結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-23 03:13:47 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 912 ms / 5,000 ms |
| コード長 | 715 bytes |
| コンパイル時間 | 3,653 ms |
| コンパイル使用メモリ | 77,636 KB |
| 実行使用メモリ | 49,268 KB |
| 最終ジャッジ日時 | 2024-06-28 16:05:49 |
| 合計ジャッジ時間 | 8,427 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
import java.util.*;
public class No120{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t = 0; t < T; t++){
int N = sc.nextInt();
int[] l = new int[N];
int[] count = new int[N];
for(int n = 0; n < N; n++){
l[n] = sc.nextInt();
}
Arrays.sort(l);
int kind = 0;
int c = 1;
for(int i = 1; i < N; i++){
if(l[i] == l[i-1]){
c++;
}else{
count[kind++] = c;
c = 1;
}
}
count[kind++] = c;
Arrays.sort(count);
int max = 0;
while(N-2 > 0 && count[N-3]>0){
max++;
count[N-3]--;
count[N-2]--;
count[N-1]--;
Arrays.sort(count);
}
System.out.println(max);
}
}
}