結果

問題 No.910 素数部分列
ユーザー rpy3cpp
提出日時 2019-10-18 21:43:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 494 bytes
コンパイル時間 1,585 ms
コンパイル使用メモリ 167,712 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 15:20:45
合計ジャッジ時間 2,818 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int counter = 0;
    int ans = 0;
    for (char s : S){
        if (s == '1'){
            ++counter;
        }else if (s == '9'){
            if (counter > 0){
                --counter;
                ++ans;
            }
        }else{
            ++ans;
        }
    }
    cout << ans + counter / 2 << endl;
    return 0;
}
0