結果

問題 No.29 パワーアップ
ユーザー tokustokus
提出日時 2021-11-18 23:00:09
言語 Java19
(openjdk 21)
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 1,863 bytes
コンパイル時間 2,608 ms
コンパイル使用メモリ 83,100 KB
実行使用メモリ 51,100 KB
最終ジャッジ日時 2023-08-27 17:40:33
合計ジャッジ時間 5,316 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
50,480 KB
testcase_01 AC 52 ms
50,892 KB
testcase_02 AC 54 ms
50,676 KB
testcase_03 AC 54 ms
50,676 KB
testcase_04 AC 54 ms
50,356 KB
testcase_05 AC 58 ms
50,632 KB
testcase_06 AC 57 ms
50,660 KB
testcase_07 AC 53 ms
50,672 KB
testcase_08 AC 54 ms
50,664 KB
testcase_09 AC 53 ms
51,100 KB
testcase_10 AC 58 ms
50,876 KB
testcase_11 AC 59 ms
50,724 KB
testcase_12 AC 54 ms
50,492 KB
testcase_13 AC 56 ms
50,500 KB
testcase_14 AC 58 ms
50,652 KB
testcase_15 AC 65 ms
50,564 KB
testcase_16 AC 61 ms
50,556 KB
testcase_17 AC 54 ms
50,664 KB
testcase_18 AC 54 ms
50,588 KB
testcase_19 AC 55 ms
50,520 KB
testcase_20 AC 55 ms
50,632 KB
testcase_21 AC 54 ms
50,776 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++;
                    if (i == itemList.length - 1) {
                    count += (j / 4);
                    break;
                }
            } else {
                j++;
            }
        }

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