結果
問題 |
No.910 素数部分列
|
ユーザー |
![]() |
提出日時 | 2019-10-18 21:35:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 597 bytes |
コンパイル時間 | 1,371 ms |
コンパイル使用メモリ | 168,408 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 15:09:21 |
合計ジャッジ時間 | 2,963 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 100000000 int main(){ int N; cin>>N; string S; cin>>S; string T = ""; int ans = 0; for(int i=0;i<N;i++){ if(S[i]=='3'||S[i]=='5'||S[i]=='7'){ ans++; continue; } T += S[i]; } reverse(T.begin(),T.end()); int cnt9=0,cnt1=0; for(int i=0;i<T.size();i++){ if(T[i]=='9'){ cnt9++; } else{ if(cnt9>0){ cnt9--; ans++; } else{ cnt1++; } } } ans+=cnt1/2; cout<<ans<<endl; return 0; }