結果
| 問題 | No.3658 Darumaka Number 2 |
| コンテスト | |
| ユーザー |
urectanc
|
| 提出日時 | 2026-08-31 21:54:27 |
| 言語 | Rust (1.97.1 + proconio + num + itertools) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 867 bytes |
| 記録 | |
| コンパイル時間 | 643 ms |
| コンパイル使用メモリ | 183,808 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-08-31 21:55:14 |
| 合計ジャッジ時間 | 3,358 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 31 WA * 14 |
ソースコード
use itertools::Itertools;
use proconio::{input, marker::Bytes};
fn main() {
input! {
mut n: Bytes
}
n.iter_mut().for_each(|n| *n -= b'0');
let mut ans = vec![];
let mut less = false;
for &n in &n {
if less {
ans.push(5);
} else {
if n > 5 {
ans.push(5);
less = true;
} else if n < 4 {
if let Some(i) = (0..ans.len()).rfind(|&i| ans[i] == 5) {
ans[i] -= 1;
ans.push(5);
} else {
ans.truncate(ans.len().saturating_sub(1));
ans.fill(5);
ans.push(5);
}
less = true;
} else {
ans.push(n);
}
}
}
println!("{}", ans.iter().join(""));
}
urectanc