結果

問題 No.29 パワーアップ
ユーザー SagToki
提出日時 2018-05-10 11:54:30
言語 Java
(openjdk 23)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 987 bytes
コンパイル時間 3,279 ms
コンパイル使用メモリ 74,948 KB
実行使用メモリ 41,752 KB
最終ジャッジ日時 2024-06-28 02:56:28
合計ジャッジ時間 7,160 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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