結果

問題 No.29 パワーアップ
ユーザー mustonmuston
提出日時 2016-05-13 15:13:17
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 905 bytes
コンパイル時間 1,937 ms
使用メモリ 37,876 KB
最終ジャッジ日時 2022-11-28 15:51:40
合計ジャッジ時間 5,717 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 102 ms
37,404 KB
testcase_01 AC 103 ms
37,512 KB
testcase_02 AC 106 ms
37,524 KB
testcase_03 AC 105 ms
37,648 KB
testcase_04 AC 102 ms
37,312 KB
testcase_05 AC 115 ms
37,516 KB
testcase_06 AC 110 ms
37,428 KB
testcase_07 AC 105 ms
37,732 KB
testcase_08 AC 106 ms
37,404 KB
testcase_09 AC 101 ms
37,316 KB
testcase_10 AC 118 ms
37,572 KB
testcase_11 AC 122 ms
37,876 KB
testcase_12 AC 102 ms
37,704 KB
testcase_13 AC 113 ms
37,712 KB
testcase_14 AC 114 ms
37,544 KB
testcase_15 AC 118 ms
37,820 KB
testcase_16 AC 115 ms
37,588 KB
testcase_17 AC 108 ms
37,568 KB
testcase_18 AC 109 ms
37,620 KB
testcase_19 AC 110 ms
37,512 KB
testcase_20 AC 105 ms
37,568 KB
testcase_21 AC 103 ms
37,364 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