結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
yosupot
|
| 提出日時 | 2019-10-18 21:40:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,090 bytes |
| コンパイル時間 | 2,024 ms |
| コンパイル使用メモリ | 193,720 KB |
| 最終ジャッジ日時 | 2025-01-07 22:45:28 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 47 |
ソースコード
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#ifdef LOCAL
struct PrettyOS {
ostream& os;
bool first;
template <class T> auto operator<<(T&& x) {
if (!first) os << ", ";
first = false;
os << x;
return *this;
}
};
template <class... T> void dbg0(T&&... t) {
(PrettyOS{cerr, true} << ... << t);
}
#define dbg(...) \
do { \
cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
dbg0(__VA_ARGS__); \
cerr << endl; \
} while (false);
#else
#define dbg(...)
#endif
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
return os << "P(" << p.first << ", " << p.second << ")";
}
template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
os << "[";
for (auto d : v) os << d << ", ";
return os << "]";
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int n;
string s;
cin >> n >> s;
int ans = 0;
int c0 = 0, c1 = 0;
for (int i = n - 1; i >= 0; i--) {
if (s[i] == '3' || s[i] == '7' || s[i] == '5') {
ans++;
continue;
}
if (s[i] == '1') {
if (c1) {
c1--;
ans++;
} else {
c0++;
}
continue;
}
if (s[i] == '9') {
if (c1) {
c1--;
ans++;
} else if (c0) {
c0--;
c1++;
}
continue;
}
}
cout << ans << endl;
return 0;
}
yosupot