結果

問題 No.29 パワーアップ
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-22 15:03:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 5,000 ms
コード長 622 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 74,572 KB
実行使用メモリ 57,808 KB
最終ジャッジ日時 2023-10-23 19:18:06
合計ジャッジ時間 6,021 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,416 KB
testcase_01 AC 128 ms
57,416 KB
testcase_02 AC 129 ms
57,452 KB
testcase_03 AC 129 ms
57,048 KB
testcase_04 AC 129 ms
57,092 KB
testcase_05 AC 143 ms
57,596 KB
testcase_06 AC 139 ms
57,572 KB
testcase_07 AC 139 ms
55,828 KB
testcase_08 AC 119 ms
56,172 KB
testcase_09 AC 115 ms
56,144 KB
testcase_10 AC 142 ms
57,512 KB
testcase_11 AC 144 ms
57,432 KB
testcase_12 AC 129 ms
57,500 KB
testcase_13 AC 144 ms
57,808 KB
testcase_14 AC 145 ms
57,568 KB
testcase_15 AC 139 ms
57,532 KB
testcase_16 AC 144 ms
57,712 KB
testcase_17 AC 120 ms
56,172 KB
testcase_18 AC 141 ms
57,524 KB
testcase_19 AC 140 ms
57,708 KB
testcase_20 AC 131 ms
57,432 KB
testcase_21 AC 129 ms
57,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[10];
        int lvUp = 0;
        int itemCnt = 0;
        for(int i=0; i<n*3; i++) {
            int getItem = in.nextInt();
            itemCnt++;
            if(num[getItem-1] == 1) {
                lvUp++;
                num[getItem-1] = 0;
                itemCnt -= 2;
            } else {
                num[getItem-1]++;
            }
        }
        System.out.println(lvUp + (int)itemCnt / 4);
    }
}
0