結果

問題 No.910 素数部分列
ユーザー wesrivery
提出日時 2019-10-19 22:48:26
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 1,064 bytes
コンパイル時間 11,693 ms
コンパイル使用メモリ 407,352 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 00:52:00
合計ジャッジ時間 13,534 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, ) = input!(usize);
    let (s, ) = input!(String);

    let mut count = 0;
    let mut snew = "".to_string();
    for c in s.chars() {
        match c {
            '3' | '5' | '7' => count += 1,
            _ => snew.push(c),
        }
    }

    let mut count1 = 0;
    let mut count9 = 0;
    for c in snew.chars() {
        match c {
            '1' => count1 += 1,
            '9' => {
                count9 += 1;
                if count1 > 0 && count9 > 0 {
                    count1 -= 1;
                    count9 -= 1;
                    count += 1;
                }
            },
            _ => {},
        }
    }

    println!("{}", count + (count1 / 2));
}

fn main() {
    solve();
}
0