結果

問題 No.29 パワーアップ
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-21 14:34:01
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 113 ms / 5,000 ms
コード長 563 bytes
コンパイル時間 1,759 ms
使用メモリ 37,804 KB
最終ジャッジ日時 2022-12-27 01:37:25
合計ジャッジ時間 5,374 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 96 ms
37,464 KB
testcase_01 AC 96 ms
37,408 KB
testcase_02 AC 99 ms
37,440 KB
testcase_03 AC 101 ms
37,436 KB
testcase_04 AC 99 ms
37,368 KB
testcase_05 AC 113 ms
37,744 KB
testcase_06 AC 107 ms
37,632 KB
testcase_07 AC 102 ms
37,532 KB
testcase_08 AC 102 ms
37,632 KB
testcase_09 AC 96 ms
37,348 KB
testcase_10 AC 112 ms
37,576 KB
testcase_11 AC 112 ms
37,604 KB
testcase_12 AC 97 ms
37,412 KB
testcase_13 AC 105 ms
37,408 KB
testcase_14 AC 110 ms
37,668 KB
testcase_15 AC 111 ms
37,804 KB
testcase_16 AC 108 ms
37,732 KB
testcase_17 AC 101 ms
37,476 KB
testcase_18 AC 106 ms
37,596 KB
testcase_19 AC 100 ms
37,352 KB
testcase_20 AC 95 ms
37,368 KB
testcase_21 AC 102 ms
37,400 KB
権限があれば一括ダウンロードができます

ソースコード

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