結果

問題 No.29 パワーアップ
ユーザー fukuseifukusei
提出日時 2017-05-22 23:03:52
言語 Java19
(openjdk 19.0.1)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 1,594 ms
実行使用メモリ 51,144 KB
最終ジャッジ日時 2023-03-27 14:31:45
合計ジャッジ時間 4,980 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
51,076 KB
testcase_01 AC 95 ms
50,920 KB
testcase_02 AC 93 ms
50,920 KB
testcase_03 AC 92 ms
50,916 KB
testcase_04 AC 91 ms
50,996 KB
testcase_05 AC 105 ms
50,908 KB
testcase_06 AC 105 ms
50,944 KB
testcase_07 AC 97 ms
50,924 KB
testcase_08 AC 100 ms
50,908 KB
testcase_09 AC 96 ms
50,868 KB
testcase_10 AC 111 ms
50,876 KB
testcase_11 AC 109 ms
50,996 KB
testcase_12 AC 93 ms
50,872 KB
testcase_13 AC 99 ms
51,084 KB
testcase_14 AC 101 ms
50,896 KB
testcase_15 AC 111 ms
51,068 KB
testcase_16 AC 106 ms
50,756 KB
testcase_17 AC 94 ms
50,924 KB
testcase_18 AC 99 ms
50,900 KB
testcase_19 AC 103 ms
50,916 KB
testcase_20 AC 99 ms
50,852 KB
testcase_21 AC 96 ms
51,144 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