結果

問題 No.99 ジャンピング駒
ユーザー ThetaTheta
提出日時 2022-10-28 13:45:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,696 KB
実行使用メモリ 18,960 KB
最終ジャッジ日時 2023-09-19 06:32:18
合計ジャッジ時間 1,251 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
18,880 KB
testcase_01 AC 61 ms
18,872 KB
testcase_02 AC 59 ms
18,804 KB
testcase_03 AC 59 ms
18,808 KB
testcase_04 AC 57 ms
18,960 KB
testcase_05 AC 59 ms
18,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    X = list(map(int, input().split()))
    if N == 1:
        print(1)

    stack = []

    for next_ in X:
        if not stack:
            stack.append(next_)
            continue
        if (stack[-1] ^ next_) & 1:
            stack.pop()
        else:
            stack.append(next_)

    print(len(stack))


if __name__ == "__main__":
    main()
0