結果

問題 No.29 パワーアップ
ユーザー shinshin
提出日時 2022-05-15 19:55:17
言語 Java19
(openjdk 21)
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 973 bytes
コンパイル時間 5,862 ms
コンパイル使用メモリ 74,916 KB
実行使用メモリ 49,792 KB
最終ジャッジ日時 2023-10-11 06:41:44
合計ジャッジ時間 6,097 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,364 KB
testcase_01 AC 44 ms
49,420 KB
testcase_02 AC 46 ms
49,364 KB
testcase_03 AC 45 ms
49,432 KB
testcase_04 AC 44 ms
49,320 KB
testcase_05 AC 45 ms
49,444 KB
testcase_06 AC 45 ms
49,348 KB
testcase_07 AC 44 ms
49,360 KB
testcase_08 AC 44 ms
49,248 KB
testcase_09 AC 44 ms
49,408 KB
testcase_10 AC 45 ms
49,280 KB
testcase_11 AC 46 ms
49,368 KB
testcase_12 AC 45 ms
49,492 KB
testcase_13 AC 45 ms
49,484 KB
testcase_14 AC 45 ms
49,500 KB
testcase_15 AC 45 ms
49,200 KB
testcase_16 AC 45 ms
49,216 KB
testcase_17 AC 45 ms
49,792 KB
testcase_18 AC 45 ms
49,176 KB
testcase_19 AC 46 ms
49,428 KB
testcase_20 AC 45 ms
49,264 KB
testcase_21 AC 45 ms
49,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class No29_3{

	public static void main(String[] args)  throws IOException{
		//パワーアップ 作り直し2回目
		int count = 0 , i;
		String[] text = readStr();
		ArrayList<String> al = new ArrayList<>();
		
		int N = Integer.parseInt(text[0]);
		for(i = 1;i <= N;i++) {
			for(String str : text[i].split(" ")) {
				if(al.contains(str)) {
					count++;
					al.remove(str);
				}else {
					al.add(str);
				}
			}
		}
		
		count += (int)(al.size() / 4);
		System.out.println(count);
	}

	public static String[] readStr() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<>();
		
		do {
			list.add(br.readLine());
		}while(br.ready());
		
		br.close();
		
		String[] text = new String[list.size()];
		list.toArray(text);
		
		return text;
		
	}
}
0