結果

問題 No.29 パワーアップ
ユーザー tsunabittsunabit
提出日時 2018-04-29 04:29:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,881 bytes
コンパイル時間 3,403 ms
コンパイル使用メモリ 71,380 KB
実行使用メモリ 56,092 KB
最終ジャッジ日時 2023-09-10 07:58:39
合計ジャッジ時間 7,891 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,568 KB
testcase_01 AC 125 ms
55,568 KB
testcase_02 AC 127 ms
55,684 KB
testcase_03 AC 129 ms
55,592 KB
testcase_04 AC 124 ms
55,740 KB
testcase_05 AC 141 ms
55,728 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 130 ms
55,588 KB
testcase_09 WA -
testcase_10 AC 143 ms
56,092 KB
testcase_11 AC 144 ms
55,388 KB
testcase_12 AC 126 ms
55,620 KB
testcase_13 WA -
testcase_14 AC 139 ms
55,492 KB
testcase_15 WA -
testcase_16 AC 140 ms
55,524 KB
testcase_17 AC 129 ms
55,716 KB
testcase_18 AC 132 ms
55,932 KB
testcase_19 AC 134 ms
55,848 KB
testcase_20 AC 124 ms
55,524 KB
testcase_21 AC 124 ms
55,712 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 / 3;
        System.out.println(t);
    }
}
0