結果

問題 No.29 パワーアップ
ユーザー yagi2yagi2
提出日時 2017-04-26 11:42:54
言語 Java19
(openjdk 19.0.1)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 1,050 bytes
コンパイル時間 2,150 ms
実行使用メモリ 38,068 KB
最終ジャッジ日時 2023-02-25 18:00:04
合計ジャッジ時間 5,740 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
37,896 KB
testcase_01 AC 103 ms
37,748 KB
testcase_02 AC 104 ms
37,784 KB
testcase_03 AC 99 ms
37,724 KB
testcase_04 AC 103 ms
37,756 KB
testcase_05 AC 112 ms
38,068 KB
testcase_06 AC 110 ms
37,796 KB
testcase_07 AC 108 ms
37,804 KB
testcase_08 AC 107 ms
37,928 KB
testcase_09 AC 105 ms
37,936 KB
testcase_10 AC 116 ms
37,752 KB
testcase_11 AC 113 ms
37,740 KB
testcase_12 AC 107 ms
37,760 KB
testcase_13 AC 109 ms
37,748 KB
testcase_14 AC 113 ms
37,852 KB
testcase_15 AC 109 ms
37,916 KB
testcase_16 AC 111 ms
37,868 KB
testcase_17 AC 105 ms
37,836 KB
testcase_18 AC 107 ms
37,788 KB
testcase_19 AC 108 ms
37,784 KB
testcase_20 AC 102 ms
37,808 KB
testcase_21 AC 102 ms
37,688 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