結果
問題 |
No.910 素数部分列
|
ユーザー |
![]() |
提出日時 | 2019-10-19 00:07:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 1,090 bytes |
コンパイル時間 | 669 ms |
コンパイル使用メモリ | 85,548 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 22:04:41 |
合計ジャッジ時間 | 2,328 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<bitset> #include<set> #include<map> #include<stack> #include<queue> #include<deque> #include<list> #include<iomanip> #include<cmath> #include<cstring> #include<functional> using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1000000007 //#define MOD 998244353 #define LINF (long long)4e18 #define jck 3.141592 using ll = long long; using Pi = pair<int,int>; using Pl = pair<ll,ll>; int main(){ int N; cin >> N; string S; cin >> S; int ans = 0; int now1 = 0; int now9 = 0; rep(i,N){ if(S[i] == '3' || S[i] == '5' || S[i] == '7') ans++; if(S[i] == '1'){ now1++; } if(S[i] == '9'){ now9++; if(now1 > 0){ now1--; now9--; ans++; } } } ans += min(now9/2,now1); now1 -= min(now9/2,now1); if(now1 > 0) ans += now1/2; cout << ans << endl; }