結果

問題 No.29 パワーアップ
ユーザー SagTokiSagToki
提出日時 2018-05-10 11:54:30
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 987 bytes
コンパイル時間 2,882 ms
使用メモリ 38,260 KB
最終ジャッジ日時 2023-01-27 17:20:53
合計ジャッジ時間 6,554 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 106 ms
37,908 KB
testcase_01 AC 104 ms
37,840 KB
testcase_02 AC 100 ms
37,748 KB
testcase_03 AC 107 ms
37,836 KB
testcase_04 AC 98 ms
37,760 KB
testcase_05 AC 113 ms
38,120 KB
testcase_06 AC 112 ms
37,964 KB
testcase_07 AC 104 ms
37,744 KB
testcase_08 AC 105 ms
37,928 KB
testcase_09 AC 99 ms
37,732 KB
testcase_10 AC 111 ms
38,084 KB
testcase_11 AC 119 ms
38,260 KB
testcase_12 AC 105 ms
37,744 KB
testcase_13 AC 103 ms
37,916 KB
testcase_14 AC 114 ms
38,064 KB
testcase_15 AC 116 ms
38,080 KB
testcase_16 AC 106 ms
37,908 KB
testcase_17 AC 105 ms
37,788 KB
testcase_18 AC 111 ms
37,924 KB
testcase_19 AC 107 ms
37,936 KB
testcase_20 AC 101 ms
37,828 KB
testcase_21 AC 100 ms
37,784 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