結果
問題 |
No.99 ジャンピング駒
|
ユーザー |
![]() |
提出日時 | 2016-01-17 21:10:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 44 ms / 5,000 ms |
コード長 | 544 bytes |
コンパイル時間 | 557 ms |
コンパイル使用メモリ | 56,184 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 20:20:53 |
合計ジャッジ時間 | 1,347 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
ソースコード
//駒を動かせない→駒を交換する、と読み替えよう //すると、奇数・偶数のペアが存在すれば互いに消すことができる //よって、|奇数の個数 - 偶数の個数|が答えとなる #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; }