結果

問題 No.29 パワーアップ
ユーザー jimanojimano
提出日時 2018-01-08 14:56:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 640 bytes
コンパイル時間 3,439 ms
コンパイル使用メモリ 72,656 KB
実行使用メモリ 55,936 KB
最終ジャッジ日時 2023-08-25 00:30:51
合計ジャッジ時間 7,521 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
53,948 KB
testcase_01 AC 127 ms
55,728 KB
testcase_02 AC 126 ms
55,700 KB
testcase_03 AC 128 ms
55,644 KB
testcase_04 AC 126 ms
55,616 KB
testcase_05 AC 142 ms
55,404 KB
testcase_06 AC 140 ms
55,776 KB
testcase_07 AC 135 ms
55,740 KB
testcase_08 AC 130 ms
55,628 KB
testcase_09 AC 126 ms
55,736 KB
testcase_10 AC 142 ms
55,904 KB
testcase_11 AC 146 ms
55,616 KB
testcase_12 AC 129 ms
55,716 KB
testcase_13 AC 144 ms
55,900 KB
testcase_14 AC 144 ms
55,516 KB
testcase_15 AC 142 ms
55,844 KB
testcase_16 AC 141 ms
55,748 KB
testcase_17 AC 132 ms
55,644 KB
testcase_18 AC 136 ms
55,936 KB
testcase_19 AC 137 ms
55,824 KB
testcase_20 AC 127 ms
55,864 KB
testcase_21 AC 130 ms
55,920 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 = upCnt + (i / 2);// 同じアイテム2つでパワーアップ
			modCnt = modCnt + (i % 2);
		}
		upCnt = upCnt + (modCnt / 4);// 任意のアイテム4つでパワーアップ

		System.out.println(upCnt);
	}	
}
0