結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-18 23:25:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 587 bytes |
| コンパイル時間 | 713 ms |
| コンパイル使用メモリ | 70,016 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 19:50:30 |
| 合計ジャッジ時間 | 2,310 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 37 |
ソースコード
#include <cmath>
#include <iostream>
#include <string>
int main() {
int N;
std::string s;
std::cin >> N;
std::cin >> s;
int cnt1 = 0, cnt9 = 0;
int ans = 0;
for (int i = 0; i < N; ++i) {
if (s[i] == '1') {
if (cnt9 >= 2) {
++ans;
--cnt9;
--cnt9;
} else if (cnt1 > 0) {
++ans;
--cnt1;
} else {
++cnt1;
}
} else if (s[i] == '9') {
if (cnt1 > 0) {
++ans;
--cnt1;
} else {
++cnt9;
}
} else {
++ans;
}
}
std::cout << ans << std::endl;
}