結果

問題 No.910 素数部分列
コンテスト
ユーザー Wataruaoki
提出日時 2019-10-19 13:09:49
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 740 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 396 ms
コンパイル使用メモリ 38,912 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-14 03:33:35
合計ジャッジ時間 2,247 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

constexpr int MAX_SIZE = 2e5 + 10;
char str[MAX_SIZE];


int main(void){
    int n; scanf("%d%s", &n, str);
    int res = 0, one = 0, nine = 0;
    REP(i, n){
        switch(str[i]){
            case '1':
                one++;
                break;
            case '3':
            case '5':
            case '7':
                res++;
                break;
            case '9':
                if(one >= 1){one--; res++;}
                else nine++;
                break;
        }
    }
    int d = (one > nine / 2) ? nine / 2 : one;
    res += d; one -= d;
    res += one / 2;
    printf("%d\n", res);

    return 0;
}
0