結果

問題 No.910 素数部分列
ユーザー phspls
提出日時 2020-02-08 16:44:38
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 12,523 ms
コンパイル使用メモリ 378,564 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-25 08:51:43
合計ジャッジ時間 14,691 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn main() {
    let mut all_data = String::new();
    std::io::stdin().read_to_string(&mut all_data).ok();
    let mut all_data = all_data.trim().split('\n').map(|s| s.trim());
    let n: usize = all_data.next().unwrap().parse().unwrap();
    let s: String = all_data.next().unwrap().chars()
        .filter(|c| c != &'3')
        .filter(|c| c != &'5')
        .filter(|c| c != &'7')
        .collect();
    let mut count = n - s.len();
    let mut one_count: usize = 0;
    for c in s.chars() {
        if c == '1' {
            one_count += 1;
        } else {
            if one_count > 0 {
                one_count -= 1;
                count += 1;
            }
        }
    }
    println!("{}", count + one_count / 2);
}
0