結果

問題 No.99 ジャンピング駒
ユーザー legosukelegosuke
提出日時 2017-11-22 17:28:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 421 bytes
コンパイル時間 1,179 ms
コンパイル使用メモリ 164,276 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 21:00:21
合計ジャッジ時間 2,443 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n;
  cin >> n;

  stack<int> st;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    x += (int)1e9;
    if (!st.empty() && x % 2 == 0 && st.top() % 2 == 1) {
      st.pop();
    } else if (!st.empty() && x % 2 == 1 && st.top() % 2 == 0) {
      st.pop();
    } else {
      st.push(x);
    }
  }

  cout << st.size() << endl;

  return 0;
}
0