結果
問題 | No.910 素数部分列 |
ユーザー |
![]() |
提出日時 | 2023-04-12 17:14:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 732 bytes |
コンパイル時間 | 4,108 ms |
コンパイル使用メモリ | 250,068 KB |
最終ジャッジ日時 | 2025-02-12 05:16:45 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 25 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=1444999999999999; ll mod=998244353; int main(){ ll n; cin >> n; string s; cin >> s; ll ans=0; ll x=0,y=0; for (ll i = 0; i < s.size(); i++) { if (s[i]=='3'||s[i]=='5'||s[i]=='7') { ans+=1; }else if (s[i]=='1') { x+=1; }else{ if (x>0) { ans+=1; x-=1; }else{ y+=1; } } } ans+=x/2; if (x%2==1&&y>=2) { ans+=1; } cout << ans << endl; }