結果

問題 No.99 ジャンピング駒
ユーザー startcppstartcpp
提出日時 2016-01-17 21:10:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 544 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 57,632 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 00:30:52
合計ジャッジ時間 1,356 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
4,348 KB
testcase_01 AC 43 ms
4,348 KB
testcase_02 AC 43 ms
4,348 KB
testcase_03 AC 43 ms
4,348 KB
testcase_04 AC 42 ms
4,348 KB
testcase_05 AC 43 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//駒を動かせない→駒を交換する、と読み替えよう
//すると、奇数・偶数のペアが存在すれば互いに消すことができる
//よって、|奇数の個数 - 偶数の個数|が答えとなる
#include <iostream>
#include <algorithm>
using namespace std;

int n;
int x[100000];

int main(){
	cin >> n;
	for( int i = 0; i < n; i++ ){
		cin >> x[i];
	}
	
	int state = 0;
	for( int i = 0; i < n; i++ ){
		if( x[i] % 2 ) state++;
		else state--;
	}
	state = max(state, -state);
	cout << state << endl;
	return 0;
}
0