結果

問題 No.29 パワーアップ
ユーザー ohagi_1182
提出日時 2017-10-21 14:34:01
言語 Java
(openjdk 23)
結果
AC  
実行時間 154 ms / 5,000 ms
コード長 563 bytes
コンパイル時間 2,460 ms
コンパイル使用メモリ 74,112 KB
実行使用メモリ 54,532 KB
最終ジャッジ日時 2024-11-21 12:30:25
合計ジャッジ時間 6,773 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[11];
		for(int i = 0 ; i < n ; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			x[a]++; x[b]++; x[c]++;
		}
		int ans = 0; int cnt = 0;
		for(int i = 0 ; i < 11 ; i++) {
			if(x[i] >= 2) {
				ans += x[i] / 2;
				if(x[i] % 2 == 1) cnt++;
			} else if(x[i] == 1 || x[i] % 2 == 1) {
				cnt++;
			}
		}
		ans += cnt / 4;
		System.out.println(ans);
 	}
}

0