結果

問題 No.29 パワーアップ
ユーザー 練習生練習生
提出日時 2015-08-21 15:37:13
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 3,246 ms
使用メモリ 37,980 KB
最終ジャッジ日時 2023-02-16 08:48:00
合計ジャッジ時間 7,158 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 100 ms
37,292 KB
testcase_01 AC 96 ms
37,420 KB
testcase_02 AC 100 ms
37,396 KB
testcase_03 AC 100 ms
37,492 KB
testcase_04 AC 104 ms
37,400 KB
testcase_05 AC 111 ms
37,680 KB
testcase_06 AC 109 ms
37,776 KB
testcase_07 AC 108 ms
37,524 KB
testcase_08 AC 108 ms
37,716 KB
testcase_09 AC 102 ms
37,468 KB
testcase_10 AC 115 ms
37,768 KB
testcase_11 AC 116 ms
37,980 KB
testcase_12 AC 103 ms
37,444 KB
testcase_13 AC 113 ms
37,660 KB
testcase_14 AC 116 ms
37,916 KB
testcase_15 AC 106 ms
37,532 KB
testcase_16 AC 105 ms
37,468 KB
testcase_17 AC 100 ms
37,444 KB
testcase_18 AC 106 ms
37,580 KB
testcase_19 AC 108 ms
37,524 KB
testcase_20 AC 99 ms
37,664 KB
testcase_21 AC 102 ms
37,388 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