結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
xuzijian629
|
| 提出日時 | 2019-10-18 21:41:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 784 bytes |
| コンパイル時間 | 1,822 ms |
| コンパイル使用メモリ | 192,512 KB |
| 最終ジャッジ日時 | 2025-01-07 22:46:33 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
string t;
int ans = 0;
int one = 0, nine = 0;
for (char c : s) {
if (!(c == '1' || c == '9')) {
ans++;
} else {
t += c;
}
}
int cur = 0;
int hoge = 0;
for (int i = (int)t.size() - 1; i >= 0; i--) {
if (t[i] == '9')
cur++;
else {
if (cur) {
ans++;
cur--;
} else {
hoge++;
if (hoge == 2) {
ans++;
hoge -= 2;
}
}
}
}
cout << ans << endl;
}
xuzijian629