結果

問題 No.910 素数部分列
ユーザー otamay6
提出日時 2019-10-19 11:30:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 167,340 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-26 23:06:00
合計ジャッジ時間 3,587 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N;cin>>N;
    string S;cin>>S;
    int iti=0,kyu=0;
    int ans=0;
    REP(i,N){
        if(S[i]=='1'){
            if(kyu>=2){
                ans++;
                kyu-=2;
            }
            else iti++;
        }
        else if(S[i]=='9'){
            if(iti>0){
                ans++;
                iti--;
            }
            else kyu++;
        }
        else ans++;
    }
    ans+=iti/2;
    cout<<ans<<endl;
}
0