結果

問題 No.29 パワーアップ
ユーザー tsunabittsunabit
提出日時 2018-04-29 04:32:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 5,000 ms
コード長 1,881 bytes
コンパイル時間 3,351 ms
コンパイル使用メモリ 72,128 KB
実行使用メモリ 55,992 KB
最終ジャッジ日時 2023-09-10 07:59:02
合計ジャッジ時間 7,404 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,720 KB
testcase_01 AC 126 ms
55,676 KB
testcase_02 AC 125 ms
55,816 KB
testcase_03 AC 127 ms
55,596 KB
testcase_04 AC 126 ms
55,520 KB
testcase_05 AC 141 ms
55,648 KB
testcase_06 AC 142 ms
55,528 KB
testcase_07 AC 136 ms
55,768 KB
testcase_08 AC 130 ms
53,636 KB
testcase_09 AC 127 ms
55,576 KB
testcase_10 AC 143 ms
55,676 KB
testcase_11 AC 144 ms
55,304 KB
testcase_12 AC 127 ms
55,864 KB
testcase_13 AC 138 ms
55,972 KB
testcase_14 AC 143 ms
55,636 KB
testcase_15 AC 140 ms
55,676 KB
testcase_16 AC 141 ms
55,992 KB
testcase_17 AC 132 ms
55,588 KB
testcase_18 AC 136 ms
55,608 KB
testcase_19 AC 135 ms
55,816 KB
testcase_20 AC 128 ms
55,508 KB
testcase_21 AC 126 ms
55,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

// ***問題文***
// Quinは、RPGをしている。
// そのRPGでは、アイテムは10種類(それぞれ番号付けされている)あり、「同じアイテム」を2つ揃えるか、「任意のアイテム」を4つ揃えるとパワーアップする仕組みがある。
// そして敵を倒したら、何かアイテムを3つもらうことができる。
// (同じアイテムがもらえることもある。)
// このとき、持てるアイテムの上限はないとし、アイテムの組み合わせは自由に決められる。(自動的にパワーアップすることはないとする。)
// N回敵を倒すと考えたとき、その時のパワーアップする最大の回数を求めてください。
// ***入力***
// N
// a1 b1 c1
// a2 b2 c2
// ・・・・
// aN bN cN
// 1行目に敵を倒す回数を表すN (1<=N<=100)が与えられる。
// 2行目以降はi(1<=i<=N)回目で敵を倒した時のもらえる3つのアイテムの番号ai,bi,ci(1<=ai,bi,ci<=10)が半角空白区切りで与えられる。
// ***出力***
// 最大のパワーアップする回数を文字列で出力してください。出力の末尾には改行をいれること。


public class No29 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[10];
        int temp = 0;
        for(int i = 0; i < n * 3; i++) {
            temp = sc.nextInt();
            a[temp - 1] = a[temp - 1] + 1;
        }
        int t = 0;
        int remain = 0;
        for(int i = 0; i < 10; i++) {
            t += a[i] / 2;
            remain += a[i] % 2;
        }
        t += remain / 4;
        System.out.println(t);
    }
}
0