結果

問題 No.910 素数部分列
ユーザー mtsd
提出日時 2019-10-18 21:49:35
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,106 bytes
コンパイル時間 858 ms
コンパイル使用メモリ 99,480 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 15:31:47
合計ジャッジ時間 2,487 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    string s;
    cin >> n >> s;
    int a = 0;
    int b = 0;
    int sm = 0;
    rep(i,n){
        if(s[i]=='1'){
            if(b>=2){
                b-=2;
                sm++;
            }else{
                a++;
            }
        }else if(s[i]=='9'){
            if(a>=1){
                a--;
                sm++;
            }else{
                b++;
            }
        }else{
            sm++;
        }
    }
    sm += a/2;
    cout << sm << endl;
    return 0;
}
0