結果

問題 No.29 パワーアップ
ユーザー muston
提出日時 2016-05-13 15:13:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 905 bytes
コンパイル時間 1,708 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 54,340 KB
最終ジャッジ日時 2024-10-05 14:19:00
合計ジャッジ時間 5,129 ms
ジャッジサーバーID
(参考情報)
judge4 / 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};
    int powerup = 0;
    int keep = 0;
    //敵を倒す回数nを入力
    int n = scan.nextInt();
    for(int i=0;i<n;i++){
    //アイテムを3つ入力する
      int a = scan.nextInt()-1;
      item[a] = item[a] + 1;
      int b = scan.nextInt()-1;
      item[b] = item[b] + 1;
      int c = scan.nextInt()-1;
      item[c] = item[c] + 1;
    }
    //パワーアップする回数を数える
    for(int i=0;i<item.length;i++){
      powerup = powerup + (item[i]/2);
      keep = keep + item[i]%2;
    }
    powerup = powerup + (keep/4);
    //最大パワーアップ数powerupを出力
    System.out.println(powerup);
  }
}
0