結果
問題 |
No.910 素数部分列
|
ユーザー |
|
提出日時 | 2019-10-20 05:31:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 1,000 ms |
コード長 | 596 bytes |
コンパイル時間 | 1,848 ms |
コンパイル使用メモリ | 191,832 KB |
最終ジャッジ日時 | 2025-01-08 00:04:01 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; int ans = 0; int one = 0, nine = 0; for (char c : s) { if (c == '3' || c == '5' || c == '7') ans++; else { if (c == '1') { one++; } if (c == '9') { if (one > 0) { one--; ans++; } else { nine++; } } } } ans += min(one, nine / 2); one -= min(one, nine / 2); ans += one / 2; cout << ans << '\n'; return 0; }