結果

問題 No.29 パワーアップ
ユーザー SagTokiSagToki
提出日時 2018-05-10 11:54:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 987 bytes
コンパイル時間 3,287 ms
コンパイル使用メモリ 71,776 KB
実行使用メモリ 57,636 KB
最終ジャッジ日時 2023-09-10 11:35:24
合計ジャッジ時間 7,815 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,900 KB
testcase_01 AC 127 ms
55,764 KB
testcase_02 AC 126 ms
55,636 KB
testcase_03 AC 131 ms
55,668 KB
testcase_04 AC 128 ms
53,924 KB
testcase_05 AC 142 ms
55,704 KB
testcase_06 AC 143 ms
55,400 KB
testcase_07 AC 137 ms
55,756 KB
testcase_08 AC 131 ms
55,692 KB
testcase_09 AC 128 ms
53,364 KB
testcase_10 AC 144 ms
55,396 KB
testcase_11 AC 148 ms
57,636 KB
testcase_12 AC 130 ms
55,768 KB
testcase_13 AC 144 ms
55,600 KB
testcase_14 AC 145 ms
55,724 KB
testcase_15 AC 143 ms
55,580 KB
testcase_16 AC 144 ms
55,700 KB
testcase_17 AC 132 ms
55,748 KB
testcase_18 AC 136 ms
55,656 KB
testcase_19 AC 138 ms
55,912 KB
testcase_20 AC 125 ms
55,936 KB
testcase_21 AC 127 ms
55,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class PowerUp {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        try{
            int[] Item = new int[10];
            int Power = 0;
            int Amari = 0;
            int Number = scanner.nextInt();
            int[] Bag = new int[Number*3];
            
            for(int i = 0 ; i < Number*3 ; i++){
                Item[scanner.nextInt() - 1] += 1;
            }
 
            //数字が重複するペアを抽出する
            for(int j = 0 ; j < Item.length ; j++){  
                Power += Item[j]/2;
                Amari += Item[j]%2;
            }
            Power += Amari / 4;
                    
            System.out.println(Power);
        
        }catch(InputMismatchException e){
            System.out.println("数字を入力してください。");
        }catch(Exception E){
            System.out.println("予期せぬエラーです。");
        }
    }   
}
0