結果

問題 No.29 パワーアップ
ユーザー 練習生練習生
提出日時 2015-08-21 15:37:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 4,737 ms
コンパイル使用メモリ 72,352 KB
実行使用メモリ 56,540 KB
最終ジャッジ日時 2023-09-25 14:20:40
合計ジャッジ時間 8,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,004 KB
testcase_01 AC 120 ms
55,824 KB
testcase_02 AC 122 ms
55,948 KB
testcase_03 AC 125 ms
56,132 KB
testcase_04 AC 121 ms
56,540 KB
testcase_05 AC 135 ms
55,568 KB
testcase_06 AC 136 ms
55,772 KB
testcase_07 AC 126 ms
55,720 KB
testcase_08 AC 131 ms
55,892 KB
testcase_09 AC 125 ms
55,576 KB
testcase_10 AC 135 ms
56,028 KB
testcase_11 AC 137 ms
56,004 KB
testcase_12 AC 124 ms
55,580 KB
testcase_13 AC 138 ms
55,644 KB
testcase_14 AC 134 ms
55,924 KB
testcase_15 AC 139 ms
56,040 KB
testcase_16 AC 136 ms
55,768 KB
testcase_17 AC 124 ms
55,548 KB
testcase_18 AC 129 ms
55,796 KB
testcase_19 AC 131 ms
53,656 KB
testcase_20 AC 122 ms
55,948 KB
testcase_21 AC 120 ms
55,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class No29 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] su = new int[10];
		int lvUp = 0;
		int itemCount = 0;
		int n = sc.nextInt();
		for(int i = 0; i < n * 3; i++){
			int getItem = sc.nextInt();
			itemCount++;
			// 同じアイテムが2つ揃う
			if(su[getItem - 1] == 1){	
				lvUp++;
				su[getItem - 1] = 0;
				itemCount -= 2;  	// 2つのアイテムを消費
			}else{
				su[getItem - 1]++;
			}
		}
		System.out.println(lvUp + (int)itemCount / 4);
		sc.close();

	}
}
0