結果
問題 |
No.910 素数部分列
|
ユーザー |
![]() |
提出日時 | 2019-10-18 23:42:21 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 904 bytes |
コンパイル時間 | 14,064 ms |
コンパイル使用メモリ | 378,756 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 20:01:14 |
合計ジャッジ時間 | 14,392 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 29 |
ソースコード
use std::io::Read; fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let _n: usize = it.next().unwrap().parse().unwrap(); let s = it.next().unwrap(); let mut c1 = 0; let mut c9 = 0; let mut ans = 0; for c in s.chars() { match c { '1' => { if c9 >= 2 { ans += 1; c9 -= 2; } else { c1 += 1; } }, '9' => { if c1 >= 1 { ans += 1; c1 -= 1; } else { c9 += 1; } }, _ => ans += 1, } } while c1 >= 2 { ans += 1; c1 -=21; } println!("{}", ans); } fn main() { run(); }