結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
tanimani364
|
| 提出日時 | 2019-10-19 06:19:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 1,000 ms |
| コード長 | 1,324 bytes |
| コンパイル時間 | 718 ms |
| コンパイル使用メモリ | 89,992 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 07:57:51 |
| 合計ジャッジ時間 | 2,379 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
void solve(){
int n;
string s;
cin>>n>>s;
int ans=0,one=0,nine=0,nine2=0;
rep(i,n){
if(s[i]=='1')++one;
if(s[i]=='9'){
if(one>nine)++nine;
else ++nine2;
}
if(s[i]=='3')++ans;
if(s[i]=='5')++ans;
if(s[i]=='7')++ans;
}
ans+=nine;//19を作れるだけ作る
one-=nine;
int cmp=min(one,nine2/2);//991を作れるだけ作る
ans+=cmp;
one-=cmp;
ans+=one/2;//11を作る
cout<<ans<<"\n";
return;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout<<fixed<<setprecision(20);
solve();
return 0;
}
tanimani364