結果

問題 No.29 パワーアップ
ユーザー yagi2yagi2
提出日時 2017-04-26 11:42:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 1,050 bytes
コンパイル時間 2,466 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 56,192 KB
最終ジャッジ日時 2023-10-11 15:11:28
合計ジャッジ時間 6,245 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,464 KB
testcase_01 AC 120 ms
56,056 KB
testcase_02 AC 119 ms
55,544 KB
testcase_03 AC 121 ms
55,588 KB
testcase_04 AC 120 ms
55,852 KB
testcase_05 AC 128 ms
55,628 KB
testcase_06 AC 129 ms
55,932 KB
testcase_07 AC 127 ms
55,720 KB
testcase_08 AC 122 ms
55,620 KB
testcase_09 AC 119 ms
55,608 KB
testcase_10 AC 130 ms
55,544 KB
testcase_11 AC 135 ms
54,104 KB
testcase_12 AC 121 ms
55,608 KB
testcase_13 AC 127 ms
55,592 KB
testcase_14 AC 131 ms
55,876 KB
testcase_15 AC 130 ms
56,192 KB
testcase_16 AC 134 ms
55,584 KB
testcase_17 AC 126 ms
55,960 KB
testcase_18 AC 129 ms
56,168 KB
testcase_19 AC 129 ms
55,632 KB
testcase_20 AC 122 ms
56,084 KB
testcase_21 AC 119 ms
55,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder.No29;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());

        Map<Integer, Integer> items = new HashMap<>();
        for (int i = 0; i < N * 3; i++) {
            int a = Integer.parseInt(sc.next());

            if (!items.containsKey(a)) items.put(a, 0);
            items.put(a, items.get(a) + 1);
        }

        int[] powerUp = {0};
        items.forEach((integer, integer2) -> {
            if (integer2 >= 2) {
                powerUp[0] += integer2 / 2;
                items.put(integer, integer2 % 2);
            }
        });

        int[] ac = {0};
        items.forEach((integer, integer2) -> {
            if (integer2 == 1) {
                ac[0]++;
            }
            if (ac[0] == 4) {
                powerUp[0]++;
                ac[0] = 0;
            }
        });

        System.out.println(powerUp[0]);
    }
}
0