結果

問題 No.29 パワーアップ
ユーザー dazy
提出日時 2016-09-08 17:59:21
言語 Java
(openjdk 23)
結果
AC  
実行時間 152 ms / 5,000 ms
コード長 948 bytes
コンパイル時間 3,756 ms
コンパイル使用メモリ 77,364 KB
実行使用メモリ 52,272 KB
最終ジャッジ日時 2024-11-15 22:19:27
合計ジャッジ時間 7,690 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        if (N < 1||N > 100) System.exit(1);
        int a, b, c;
        int[] item = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

        for (int i = 0; i < N; i++) {
            a = scan.nextInt();
            b = scan.nextInt();
            c = scan.nextInt();
            if (!match(a,b,c)) System.exit(1);
            item[a-1]++; item[b-1]++; item[c-1]++;
        }

        int ev = 0;
        int left = 0;
        for (int i = 0; i < 10; i++) {
            if (item[i] > 1) {
                ev += item[i]/2;
            }
            left += item[i]%2;
        }
        ev += left/4;

        System.out.println(ev);
    }

    public static boolean match (int... args) {
        for (int i : args) {
            if (i < 1||i > 10) return false;
        }
        return true;
    }
}
0