結果

問題 No.99 ジャンピング駒
ユーザー hackthionhackthion
提出日時 2020-01-18 15:47:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 1,132 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 163,648 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 23:06:24
合計ジャッジ時間 2,495 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef pair<int, int> pint;
typedef vector<pint> vpint;
typedef double ld;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  ll N, odd = 0, even = 0;
  cin >> N;
  forn (i, N) {
    ll X;
    cin >> X;
    if (X % 2) ++odd;
    else ++even;
  }
  if (even == odd) puts("0");
  else printf("%Ld\n", N - (min(even, odd) * 2));
  return 0;
}

0