結果

問題 No.29 パワーアップ
ユーザー めうめう🎒めうめう🎒
提出日時 2016-05-09 21:51:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 165 ms / 5,000 ms
コード長 838 bytes
コンパイル時間 2,294 ms
コンパイル使用メモリ 78,464 KB
実行使用メモリ 54,380 KB
最終ジャッジ日時 2024-04-15 14:59:22
合計ジャッジ時間 6,540 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
53,836 KB
testcase_01 AC 142 ms
53,976 KB
testcase_02 AC 142 ms
54,076 KB
testcase_03 AC 147 ms
54,284 KB
testcase_04 AC 140 ms
53,968 KB
testcase_05 AC 154 ms
54,304 KB
testcase_06 AC 154 ms
54,092 KB
testcase_07 AC 148 ms
54,136 KB
testcase_08 AC 147 ms
54,036 KB
testcase_09 AC 143 ms
54,076 KB
testcase_10 AC 157 ms
54,380 KB
testcase_11 AC 156 ms
54,196 KB
testcase_12 AC 142 ms
54,060 KB
testcase_13 AC 157 ms
54,100 KB
testcase_14 AC 165 ms
53,972 KB
testcase_15 AC 155 ms
54,140 KB
testcase_16 AC 157 ms
54,296 KB
testcase_17 AC 144 ms
54,212 KB
testcase_18 AC 147 ms
54,300 KB
testcase_19 AC 146 ms
54,352 KB
testcase_20 AC 142 ms
54,200 KB
testcase_21 AC 138 ms
53,956 KB
権限があれば一括ダウンロードができます

ソースコード

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