#include #include int Array_Collect(const int N, int tmp[], int tmp2[]) { // 残っている数字をtmp配列にまとめる int j = 0,cnt = 0; for (int i = 0; i < N ; i++) { if ((tmp[i] != NULL)) { tmp2[j++] = tmp[i]; cnt++; } } return cnt; } void Array_Jump(const int N, int tmp[]) { for (int i = 0; i < N; i++) { // 奇数偶数で隣り合うものを消去 if ((tmp[i] % 2 == 0 && tmp[i + 1] % 2 != 0) || (tmp[i] % 2 != 0 && tmp[i + 1] % 2 == 0)) { tmp[i] = NULL; tmp[i + 1] = NULL; i++; } } } int main() { int i = 0, j = 0, N; int tmp[20][100] = {NULL}; scanf("%d", &N); int cnt = N - 1; for (i = 0; i < N ; i++) { scanf("%d", &tmp[0][i]); } i = 0; while (j++ < 10) { if (cnt > 1) { Array_Jump(cnt-1, tmp[i]); cnt = Array_Collect(N, tmp[i], tmp[i+1]); i++; } } printf("%d\n", cnt); return 0; }