結果
問題 | No.99 ジャンピング駒 |
ユーザー |
|
提出日時 | 2017-11-22 17:28:10 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 41 ms / 5,000 ms |
コード長 | 421 bytes |
コンパイル時間 | 1,371 ms |
コンパイル使用メモリ | 162,684 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-26 11:17:16 |
合計ジャッジ時間 | 2,486 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
ソースコード
#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;}