結果
問題 |
No.910 素数部分列
|
ユーザー |
![]() |
提出日時 | 2019-10-18 22:46:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 885 bytes |
コンパイル時間 | 1,182 ms |
コンパイル使用メモリ | 158,572 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 17:55:06 |
合計ジャッジ時間 | 2,723 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 42 |
ソースコード
#include "bits/stdc++.h" #define REP(i, n) for(int i = 0; i < int(n); i++) #define FOR(i,n,m) for(int i = int(n); i < int(m); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; const int INF = 1e9 + 6; const ll LLINF = 1e18 + 1; int main() { int n; cin >> n; string s; cin >> s; int ans = 0; bool one = false; int cnt_1 = 0, cnt_9_1 = 0, cnt_9_2 = 0; REP(i, n) { if (s[i] == '3' || s[i] == '5' || s[i] == '7') { ans++; } else if (s[i] == '1') { cnt_1++; one = true; } else { if (one) { cnt_9_2++; } else { cnt_9_1++; } } } ans += (cnt_1 >> 1); if (cnt_1 & 1 == 1 && (cnt_9_2 >= 1 || cnt_9_1 >= 2)) { ans++; } cout << ans << endl; return 0; }