結果

問題 No.99 ジャンピング駒
ユーザー shinshin
提出日時 2022-06-05 17:36:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 250 ms / 5,000 ms
コード長 858 bytes
コンパイル時間 3,862 ms
コンパイル使用メモリ 76,468 KB
実行使用メモリ 64,008 KB
最終ジャッジ日時 2023-10-21 03:14:15
合計ジャッジ時間 6,266 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 244 ms
61,360 KB
testcase_01 AC 243 ms
63,152 KB
testcase_02 AC 250 ms
63,308 KB
testcase_03 AC 236 ms
63,164 KB
testcase_04 AC 239 ms
64,008 KB
testcase_05 AC 236 ms
63,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class No99 {

	public static void main(String[] args) throws IOException{
		//ジャンピング駒
		String[] str = readStr();
		
		int N = Integer.parseInt(str[0]) , count = 0;
		String[] X = str[1].split(" ");
		
		for(int i = 0;i < N;i++) {
			if(Integer.parseInt(X[i]) % 2 == 0) {
				count += 1;
			}else {
				count -= 1;
			}
		}
		
		System.out.println((int)Math.abs(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