結果
問題 |
No.910 素数部分列
|
ユーザー |
![]() |
提出日時 | 2019-10-18 22:15:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 856 bytes |
コンパイル時間 | 1,931 ms |
コンパイル使用メモリ | 167,980 KB |
実行使用メモリ | 13,888 KB |
最終ジャッジ日時 | 2024-06-25 17:11:18 |
合計ジャッジ時間 | 6,911 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 11 TLE * 1 -- * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1e9 + 7; const int inf = (1 << 30) - 1; const ll infll = (1LL << 61) - 1; #define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) int N, ans, one, nine, other; string s, t = ""; int main() { cin >> N >> s; for (int i = 0; i < N; i++) { if (s[i] == '1') one++, t = t + "1"; else if (s[i] == '9') nine++, t = t + "9"; else ans++; } N = t.size(); int now_one = 0, now_nine = 0; for (int i = 0; i < N; i++) { if (t[i] == '1') { now_one++; } else { now_nine++; if (now_one > 0) now_one--, now_nine--, ans++; } } ans += now_one / 2; cout << ans << endl; }