結果

問題 No.29 パワーアップ
ユーザー fukuseifukusei
提出日時 2017-05-22 23:03:52
言語 Java19
(openjdk 19.0.1)
結果
AC  
実行時間 150 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 71,772 KB
実行使用メモリ 57,688 KB
最終ジャッジ日時 2023-07-19 11:49:57
合計ジャッジ時間 6,094 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,528 KB
testcase_01 AC 130 ms
55,736 KB
testcase_02 AC 129 ms
55,844 KB
testcase_03 AC 132 ms
55,756 KB
testcase_04 AC 130 ms
55,820 KB
testcase_05 AC 144 ms
55,868 KB
testcase_06 AC 140 ms
55,964 KB
testcase_07 AC 140 ms
55,836 KB
testcase_08 AC 129 ms
55,780 KB
testcase_09 AC 129 ms
56,032 KB
testcase_10 AC 146 ms
55,880 KB
testcase_11 AC 150 ms
57,688 KB
testcase_12 AC 130 ms
55,944 KB
testcase_13 AC 141 ms
55,704 KB
testcase_14 AC 145 ms
55,932 KB
testcase_15 AC 142 ms
55,748 KB
testcase_16 AC 140 ms
55,960 KB
testcase_17 AC 131 ms
56,132 KB
testcase_18 AC 133 ms
55,952 KB
testcase_19 AC 135 ms
56,240 KB
testcase_20 AC 129 ms
55,668 KB
testcase_21 AC 131 ms
56,008 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