結果

問題 No.29 パワーアップ
ユーザー tokustokus
提出日時 2021-11-18 22:53:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,728 bytes
コンパイル時間 5,079 ms
コンパイル使用メモリ 78,980 KB
実行使用メモリ 53,196 KB
最終ジャッジ日時 2023-08-27 17:32:41
合計ジャッジ時間 6,846 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
50,548 KB
testcase_01 AC 51 ms
50,952 KB
testcase_02 AC 53 ms
50,556 KB
testcase_03 WA -
testcase_04 AC 50 ms
50,496 KB
testcase_05 WA -
testcase_06 AC 54 ms
50,736 KB
testcase_07 AC 52 ms
50,908 KB
testcase_08 WA -
testcase_09 AC 53 ms
50,960 KB
testcase_10 WA -
testcase_11 AC 59 ms
50,744 KB
testcase_12 WA -
testcase_13 AC 51 ms
50,572 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 53 ms
50,564 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 55 ms
50,624 KB
testcase_21 AC 54 ms
50,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.stream.Stream;

class Main {
    public static void main(String[] args) {
        no29();
    }

// No.29 パワーアップ
    private static void no29() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        // 敵を倒す回数
        int turn;
        // もらえるアイテム
        int[] itemList;

        try {
            String co = reader.readLine();
            turn = Integer.parseInt(co);

            int[][] items = new int[turn][];

            itemList = new int[turn * 3];

            for (int i = 0, k = 0; i < turn; i++) {
                String line = reader.readLine();
                items[i] = Stream.of(line.split(" ")).mapToInt(Integer::parseInt).toArray();
                for (int j = 0; j < 3; j++) {
                    itemList[k] = items[i][j];
                    k++;
                }
            }
            reader.close();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }

        Arrays.sort(itemList);

        // レベルアップ回数
        int count = 0;

        // 重複値と任意の値をカウントする
        for (int i = 0, j = 0; i < itemList.length; i++) {

            if (i == itemList.length - 1) {
                j++;
                count += (j / 4);
                break;
            }

            if (itemList[i] == itemList[i + 1]) {
                count++;
                i++;
            } else {
                j++;
            }
        }

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