結果
問題 |
No.910 素数部分列
|
ユーザー |
|
提出日時 | 2021-02-18 19:16:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 604 bytes |
コンパイル時間 | 1,971 ms |
コンパイル使用メモリ | 196,508 KB |
最終ジャッジ日時 | 2025-01-18 22:34:27 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int ret = 0; stack<int> stk; for (int i = 0; i < n; i++) { char c; cin >> c; if (c == '1') { stk.push(1); } else if (c == '9') { if (!stk.empty() && stk.top() == 1) { stk.pop(); ++ret; } else { stk.push(9); } } else { ++ret; } } int one = 0; while (!stk.empty()) { if (stk.top() == 1) ++one; stk.pop(); } ret += one / 2; cout << ret << endl; return 0; }