結果

問題 No.29 パワーアップ
ユーザー dazydazy
提出日時 2016-09-08 17:59:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 5,000 ms
コード長 948 bytes
コンパイル時間 3,501 ms
コンパイル使用メモリ 73,756 KB
実行使用メモリ 57,684 KB
最終ジャッジ日時 2023-08-09 23:52:49
合計ジャッジ時間 7,660 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,568 KB
testcase_01 AC 127 ms
55,960 KB
testcase_02 AC 127 ms
55,584 KB
testcase_03 AC 129 ms
55,688 KB
testcase_04 AC 127 ms
55,680 KB
testcase_05 AC 143 ms
55,788 KB
testcase_06 AC 142 ms
55,600 KB
testcase_07 AC 135 ms
57,684 KB
testcase_08 AC 132 ms
55,784 KB
testcase_09 AC 128 ms
55,664 KB
testcase_10 AC 144 ms
55,644 KB
testcase_11 AC 145 ms
55,320 KB
testcase_12 AC 130 ms
55,888 KB
testcase_13 AC 141 ms
55,604 KB
testcase_14 AC 143 ms
55,788 KB
testcase_15 AC 142 ms
55,684 KB
testcase_16 AC 143 ms
55,592 KB
testcase_17 AC 134 ms
55,568 KB
testcase_18 AC 136 ms
55,536 KB
testcase_19 AC 138 ms
55,648 KB
testcase_20 AC 129 ms
55,828 KB
testcase_21 AC 128 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

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