結果

問題 No.99 ジャンピング駒
ユーザー NEEHATOVNEEHATOV
提出日時 2020-06-06 09:57:44
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,197 bytes
コンパイル時間 1,820 ms
コンパイル使用メモリ 29,428 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 20:47:19
合計ジャッジ時間 2,018 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>


void Array_Collect(const int N, int tmp[], int tmp2[],int umu[])
{
    // 残っている数字をtmp配列にまとめる
    int j = 0;
    for (int i = 0; i < N ; i++) {
        if ((umu[i] != 1)) {
            tmp2[j++] = tmp[i];
        }
        else {
           umu[i] = 0;
        }
    }
}
int Array_Jump(const int N, int tmp[],int umu[],int cnt)
{
    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)) {
            umu[i] = 1; umu[i+1] = 1;
            i++;
            cnt -= 2;
        }
    }
    return cnt;
}
int main() {

    int i = 0, j = 0, N;
    int tmp[20][10000];
    scanf("%d", &N);
    int cnt = N, cnt2 = N, umu[100] = { 0 };
    for (i = 0; i < N ; i++) {
        scanf("%d", &tmp[0][i]);
    }
    
    i = 0;
    while (j++ < 10)
    {
        if (cnt2 > 1) {
            if (j == 1) cnt2 -= 2;
            cnt2 = Array_Jump(cnt2, tmp[i], umu, cnt2);
            Array_Collect(N, tmp[i], tmp[i+1], umu);
            i++;
        }
    }
    printf("%d\n", cnt2);
    return 0;
}
0