結果

問題 No.29 パワーアップ
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-22 15:03:59
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 115 ms / 5,000 ms
コード長 622 bytes
コンパイル時間 1,814 ms
使用メモリ 51,168 KB
最終ジャッジ日時 2022-11-21 23:41:04
合計ジャッジ時間 5,376 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 103 ms
50,956 KB
testcase_01 AC 100 ms
51,016 KB
testcase_02 AC 96 ms
50,912 KB
testcase_03 AC 102 ms
50,920 KB
testcase_04 AC 98 ms
51,044 KB
testcase_05 AC 107 ms
50,984 KB
testcase_06 AC 110 ms
51,076 KB
testcase_07 AC 101 ms
50,896 KB
testcase_08 AC 101 ms
50,876 KB
testcase_09 AC 102 ms
50,904 KB
testcase_10 AC 115 ms
48,972 KB
testcase_11 AC 115 ms
51,084 KB
testcase_12 AC 101 ms
51,052 KB
testcase_13 AC 109 ms
50,824 KB
testcase_14 AC 112 ms
50,744 KB
testcase_15 AC 111 ms
50,916 KB
testcase_16 AC 109 ms
50,956 KB
testcase_17 AC 99 ms
50,988 KB
testcase_18 AC 111 ms
51,168 KB
testcase_19 AC 108 ms
50,936 KB
testcase_20 AC 101 ms
51,088 KB
testcase_21 AC 100 ms
51,028 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