結果

問題 No.29 パワーアップ
ユーザー abcabc
提出日時 2016-10-21 11:39:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 841 bytes
コンパイル時間 3,549 ms
コンパイル使用メモリ 71,172 KB
実行使用メモリ 58,116 KB
最終ジャッジ日時 2023-08-15 09:47:00
合計ジャッジ時間 7,733 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
55,976 KB
testcase_01 AC 113 ms
55,748 KB
testcase_02 AC 115 ms
55,984 KB
testcase_03 AC 115 ms
55,708 KB
testcase_04 AC 111 ms
56,196 KB
testcase_05 AC 130 ms
56,092 KB
testcase_06 AC 126 ms
56,716 KB
testcase_07 AC 120 ms
56,056 KB
testcase_08 AC 117 ms
55,712 KB
testcase_09 AC 116 ms
55,912 KB
testcase_10 AC 127 ms
56,088 KB
testcase_11 AC 139 ms
58,116 KB
testcase_12 AC 115 ms
55,664 KB
testcase_13 AC 127 ms
55,844 KB
testcase_14 AC 127 ms
55,664 KB
testcase_15 AC 125 ms
55,908 KB
testcase_16 AC 124 ms
55,792 KB
testcase_17 AC 116 ms
55,436 KB
testcase_18 AC 121 ms
55,848 KB
testcase_19 AC 122 ms
56,096 KB
testcase_20 AC 112 ms
56,096 KB
testcase_21 AC 116 ms
55,828 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 ItemsTotal[] = new int[10];

        for (int i = 0; i < n; i++) {

            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();

            ItemsTotal[a - 1]++;
            ItemsTotal[b - 1]++;
            ItemsTotal[c - 1]++;

        }

        int powerUp = 0;
        int other = 0;
        for (int i = 0; i < 10; i++) {

            if (ItemsTotal[i] >= 2) {
                powerUp += ItemsTotal[i] / 2;
            }

            other += ItemsTotal[i] % 2;

        }

        int maxPowerUp = powerUp + (other / 4);

        //int maxPowerUp = other / 4;

        System.out.println(maxPowerUp);

    }

}
0