結果

問題 No.29 パワーアップ
ユーザー muston
提出日時 2016-05-13 16:55:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 981 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 74,400 KB
実行使用メモリ 54,484 KB
最終ジャッジ日時 2024-10-05 14:20:13
合計ジャッジ時間 6,210 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
/*yukicoder 問題No.29 パワーアップ*/
class No29 {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    //配列[10]を作る(初期値は0)
    int[] item = {0,0,0,0,0,0,0,0,0,0};  //10種類のアイテム
    int powerup = 0;  //パワーアップ回数
    int keep = 0;  //同一アイテムを2で割った余りのアイテムの個数
    //敵を倒す回数nを入力
    int n = scan.nextInt();
    for(int i=0;i<n;i++){
    //アイテムを3つ入力する
      int idx1 = scan.nextInt()-1;
      item[idx1]++;
      int idx2 = scan.nextInt()-1;
      item[idx2]++;
      int idx3 = scan.nextInt()-1;
      item[idx3]++;
    }
    //パワーアップする回数を数える
    for(int i=0;i<item.length;i++){
      powerup +=item[i]/2;
      keep +=item[i]%2;
    }
    powerup += (keep/4);
    //最大パワーアップ数powerupを出力
    System.out.println(powerup);
  }
}
0