結果

問題 No.29 パワーアップ
ユーザー jimanojimano
提出日時 2018-01-08 15:00:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 611 bytes
コンパイル時間 3,705 ms
コンパイル使用メモリ 71,980 KB
実行使用メモリ 56,324 KB
最終ジャッジ日時 2023-08-25 00:34:23
合計ジャッジ時間 7,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,956 KB
testcase_01 AC 122 ms
55,696 KB
testcase_02 AC 123 ms
55,732 KB
testcase_03 AC 126 ms
55,936 KB
testcase_04 AC 121 ms
55,812 KB
testcase_05 AC 138 ms
56,160 KB
testcase_06 AC 136 ms
56,172 KB
testcase_07 AC 132 ms
55,944 KB
testcase_08 AC 126 ms
56,324 KB
testcase_09 AC 123 ms
56,088 KB
testcase_10 AC 138 ms
55,744 KB
testcase_11 AC 153 ms
55,736 KB
testcase_12 AC 124 ms
55,688 KB
testcase_13 AC 137 ms
55,812 KB
testcase_14 AC 138 ms
56,312 KB
testcase_15 AC 138 ms
55,612 KB
testcase_16 AC 137 ms
55,460 KB
testcase_17 AC 126 ms
55,700 KB
testcase_18 AC 131 ms
55,884 KB
testcase_19 AC 132 ms
55,856 KB
testcase_20 AC 123 ms
56,108 KB
testcase_21 AC 123 ms
56,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;
import java.util.Scanner;

public class No0029 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] items = new int[10];

		// アイテムを格納
		for (int i = 0; i < N * 3; i++) {
			int itemNum = sc.nextInt();
			items[itemNum - 1] = items[itemNum - 1] + 1;
		}

		int upCnt = 0;
		int modCnt = 0;
		for (int i : items) {
			upCnt += i / 2;// 同じアイテム2つでパワーアップ
			modCnt += i % 2;
		}
		upCnt += modCnt / 4;// 任意のアイテム4つでパワーアップ
		System.out.println(upCnt);
	}	
}
0