結果

問題 No.29 パワーアップ
ユーザー めうめう🎒
提出日時 2016-05-09 21:51:51
言語 Java
(openjdk 23)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 838 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 77,300 KB
実行使用メモリ 41,836 KB
最終ジャッジ日時 2024-10-05 13:15:58
合計ジャッジ時間 6,443 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;


public class Main {
	private int n;
	private int[] how;
	
	Main(){
		how = new int[11];
	}
	
	public void setN(int n){
		this.n = n;
	}
	
	public void plusHow(int a,int b,int c){
		this.how[a]++;
		this.how[b]++;
		this.how[c]++;
	}
	
	public int ans(){
		int last = 0;
		int ans = 0;
		for(int i = 0;i < 10;i++){
			ans += how[i] / 2;
			last += how[i] % 2;
		}
		ans += last / 4;
		return ans;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main();
		int n = sc.nextInt();
		m.setN(n);
		int a,b,c;
		for(int i = 0;i < n;i++){
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			a--;
			b--;
			c--;
			m.plusHow(a, b, c);
		}
		System.out.println(m.ans());
	}
}
0