結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2019-10-18 23:42:47 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 904 bytes |
| コンパイル時間 | 12,463 ms |
| コンパイル使用メモリ | 384,600 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 20:01:34 |
| 合計ジャッジ時間 | 14,223 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 22 |
ソースコード
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 -= 2;
}
println!("{}", ans);
}
fn main() {
run();
}
akakimidori