結果

問題 No.910 素数部分列
ユーザー ngtkana
提出日時 2020-03-29 18:38:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 543 bytes
コンパイル時間 6,340 ms
コンパイル使用メモリ 192,148 KB
最終ジャッジ日時 2025-01-09 10:52:01
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    lint ans=0,one=0,nine=0;
    while(n--){
        char c;std::cin>>c;
        if(c=='3'||c=='5'||c=='7')ans++;
        if(c=='1')one++;
        if(c=='9'){
            if(!one)nine++;
            else one--,ans++;
        }
    }
    lint d=std::min(nine/2,one);
    std::cout<<ans+d+(one-d)/2<<'\n';
}
0