結果
問題 |
No.910 素数部分列
|
ユーザー |
![]() |
提出日時 | 2019-10-19 00:01:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 561 bytes |
コンパイル時間 | 1,493 ms |
コンパイル使用メモリ | 166,028 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 22:04:14 |
合計ジャッジ時間 | 3,026 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; int main(){ int n; cin >> n; string s; cin >> s; int res = 0,cnt1 = 0,cnt9 = 0; rep(i,n) { if (s[i] == '3' || s[i] == '5' || s[i] == '7') res++; if (s[i] == '1') cnt1++; if (s[i] == '9') { cnt9++; if (cnt1 > 0) cnt1--,cnt9--,res++; } } int cnt991 = min(cnt9/2, cnt1); res += cnt991; res += (cnt1 - cnt991)/2; cout << res << endl; return 0; }