結果

問題 No.29 パワーアップ
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-23 18:27:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 1,024 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 72,392 KB
実行使用メモリ 49,656 KB
最終ジャッジ日時 2023-09-29 15:57:42
合計ジャッジ時間 3,844 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
49,172 KB
testcase_01 AC 36 ms
49,256 KB
testcase_02 AC 36 ms
49,352 KB
testcase_03 AC 35 ms
49,372 KB
testcase_04 AC 36 ms
49,204 KB
testcase_05 AC 38 ms
49,284 KB
testcase_06 AC 39 ms
49,188 KB
testcase_07 AC 36 ms
49,180 KB
testcase_08 AC 38 ms
49,656 KB
testcase_09 AC 37 ms
49,504 KB
testcase_10 AC 40 ms
49,228 KB
testcase_11 AC 37 ms
49,208 KB
testcase_12 AC 35 ms
49,456 KB
testcase_13 AC 36 ms
49,088 KB
testcase_14 AC 37 ms
49,504 KB
testcase_15 AC 37 ms
49,180 KB
testcase_16 AC 37 ms
49,148 KB
testcase_17 AC 38 ms
49,368 KB
testcase_18 AC 40 ms
49,476 KB
testcase_19 AC 39 ms
49,500 KB
testcase_20 AC 37 ms
49,200 KB
testcase_21 AC 35 ms
49,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        int[] items = new int[10];

        String[] line;
        for (int i = 0; i < N; i++) {
            line = reader.readLine().split(" ");
            for (int j = 0; j < 3; j++) {
                items[Integer.parseInt(line[j]) - 1] += 1;
            }
        }

        int powerUpTimes = 0;
        int fourItemsLevelUpCounter = 0;
        for (int i = 0; i < 10; i++) {
            while (items[i] >= 2) {
                items[i] -= 2;
                powerUpTimes += 1;
            }
            if (items[i] == 1) {
                fourItemsLevelUpCounter += 1;
            }
        }

        powerUpTimes += (fourItemsLevelUpCounter / 4);

        System.out.println(powerUpTimes);
    }
}
0