結果

問題 No.29 パワーアップ
ユーザー fukuseifukusei
提出日時 2017-05-22 23:03:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 74,408 KB
実行使用メモリ 57,904 KB
最終ジャッジ日時 2023-10-19 14:17:54
合計ジャッジ時間 6,446 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
57,476 KB
testcase_01 AC 135 ms
57,480 KB
testcase_02 AC 131 ms
55,496 KB
testcase_03 AC 135 ms
57,672 KB
testcase_04 AC 137 ms
57,640 KB
testcase_05 AC 152 ms
57,616 KB
testcase_06 AC 147 ms
57,708 KB
testcase_07 AC 143 ms
57,736 KB
testcase_08 AC 139 ms
57,664 KB
testcase_09 AC 136 ms
57,512 KB
testcase_10 AC 153 ms
57,372 KB
testcase_11 AC 149 ms
57,676 KB
testcase_12 AC 136 ms
57,512 KB
testcase_13 AC 150 ms
57,360 KB
testcase_14 AC 150 ms
57,732 KB
testcase_15 AC 149 ms
57,572 KB
testcase_16 AC 152 ms
57,904 KB
testcase_17 AC 136 ms
57,632 KB
testcase_18 AC 144 ms
57,732 KB
testcase_19 AC 144 ms
57,508 KB
testcase_20 AC 134 ms
57,636 KB
testcase_21 AC 136 ms
57,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class test{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int item[] = new int [N*3]; 
		int PowerUp = 0;
		int fourUp = 0;
		
		//値の格納
		for(int i=0; i<item.length; i++){
			item[i] = sc.nextInt();
		}
		
		//重複のカウント
		for(int i=0; i<item.length; i++){
			for(int j=0; j<item.length; j++){
				if(item[i] != 0 && i != j && item[i] == item[j]){
					item[i] = 0;
					item[j] = 0;
					PowerUp ++;
				}
			}
		}
		
		//任意の4つのカウント
		for(int i=0; i<item.length; i++){
			if(item[i] != 0){
				item[i] = 0;
				fourUp ++;
			}
		}
		PowerUp += fourUp / 4;
		
		System.out.println(PowerUp);
	}
}
0