結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー mitsuomitsuo
提出日時 2016-05-15 21:42:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 879 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 77,972 KB
実行使用メモリ 48,628 KB
最終ジャッジ日時 2024-04-15 22:13:01
合計ジャッジ時間 5,832 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package jp.fedom.challange.yuki.l2.q120;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public 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();
			long[] L = new long[N];
			for (int j = 0; j < N; j++) {
				L[j] = sc.nextLong();
			}
			System.out.println(solve(N, L));
		}
		sc.close();
	}

	public static int solve(int N, long[] L) {
		int c = 0;
		while (L.length - c >= 3) {
			List<Long> k = new ArrayList<>();
			for (int i = 0; i < L.length; i++) {
				if (L[i] == -1) {
					continue;
				}
				if (k.contains(L[i])) {
					continue;
				}
				k.add(L[i]);
				L[i] = -1;
				if (k.size() == 3) {
					break;
				}
			}
			if (k.size() == 3) {
				c += 3;
			} else {
				break;
			}

		}

		return c / 3;
	}
}
0