結果

問題 No.29 パワーアップ
ユーザー mustonmuston
提出日時 2016-05-13 16:55:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 981 bytes
コンパイル時間 2,302 ms
コンパイル使用メモリ 77,936 KB
実行使用メモリ 54,524 KB
最終ジャッジ日時 2024-04-15 15:30:36
合計ジャッジ時間 6,372 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
54,012 KB
testcase_01 AC 140 ms
54,008 KB
testcase_02 AC 136 ms
54,124 KB
testcase_03 AC 141 ms
54,084 KB
testcase_04 AC 136 ms
54,076 KB
testcase_05 AC 162 ms
54,264 KB
testcase_06 AC 153 ms
54,296 KB
testcase_07 AC 145 ms
54,080 KB
testcase_08 AC 143 ms
54,092 KB
testcase_09 AC 139 ms
54,352 KB
testcase_10 AC 154 ms
54,396 KB
testcase_11 AC 152 ms
54,232 KB
testcase_12 AC 140 ms
54,064 KB
testcase_13 AC 150 ms
54,148 KB
testcase_14 AC 162 ms
54,240 KB
testcase_15 AC 150 ms
54,432 KB
testcase_16 AC 150 ms
54,332 KB
testcase_17 AC 146 ms
53,912 KB
testcase_18 AC 155 ms
54,524 KB
testcase_19 AC 144 ms
54,508 KB
testcase_20 AC 140 ms
54,028 KB
testcase_21 AC 136 ms
54,316 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};  //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