結果

問題 No.29 パワーアップ
ユーザー mustonmuston
提出日時 2016-05-13 15:13:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 177 ms / 5,000 ms
コード長 905 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 73,980 KB
実行使用メモリ 42,256 KB
最終ジャッジ日時 2024-04-15 15:30:00
合計ジャッジ時間 7,023 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
41,584 KB
testcase_01 AC 152 ms
41,288 KB
testcase_02 AC 152 ms
41,736 KB
testcase_03 AC 157 ms
41,512 KB
testcase_04 AC 152 ms
41,148 KB
testcase_05 AC 167 ms
41,864 KB
testcase_06 AC 167 ms
41,668 KB
testcase_07 AC 159 ms
41,312 KB
testcase_08 AC 158 ms
41,452 KB
testcase_09 AC 158 ms
41,304 KB
testcase_10 AC 173 ms
41,864 KB
testcase_11 AC 177 ms
42,256 KB
testcase_12 AC 156 ms
41,592 KB
testcase_13 AC 167 ms
41,796 KB
testcase_14 AC 169 ms
41,820 KB
testcase_15 AC 168 ms
41,636 KB
testcase_16 AC 170 ms
41,448 KB
testcase_17 AC 156 ms
41,480 KB
testcase_18 AC 162 ms
41,716 KB
testcase_19 AC 166 ms
41,532 KB
testcase_20 AC 159 ms
41,184 KB
testcase_21 AC 153 ms
41,604 KB
権限があれば一括ダウンロードができます

ソースコード

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