結果

問題 No.99 ジャンピング駒
ユーザー uafr_csuafr_cs
提出日時 2015-05-15 03:59:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 676 ms / 5,000 ms
コード長 598 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 71,284 KB
実行使用メモリ 62,600 KB
最終ジャッジ日時 2023-09-20 08:01:13
合計ジャッジ時間 7,378 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 676 ms
61,508 KB
testcase_01 AC 676 ms
61,788 KB
testcase_02 AC 667 ms
62,376 KB
testcase_03 AC 653 ms
62,396 KB
testcase_04 AC 650 ms
62,600 KB
testcase_05 AC 659 ms
62,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		long[] arr = new long[N];
		for(int i = 0; i < N; i++){
			arr[i] = sc.nextLong();
		}
		Arrays.sort(arr);
		for(int i = 0; i < N; i++){
			arr[i] = Math.abs(arr[i]) % 2;
		}
		
		int ones = 0, zeros = 0;
		for(int i = 0; i < N; i++){
			if(arr[i] == 0){
				zeros++;
			}else{
				ones++;
			}
		}
		
		System.out.println(Math.max(ones, zeros) - Math.min(ones, zeros));
		
	}
	
}
0