結果

問題 No.3658 Darumaka Number 2
コンテスト
ユーザー urectanc
提出日時 2026-08-31 22:05:56
言語 Rust
(1.99.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 3 ms / 2,000 ms
+ 190µs
コード長 572 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,729 ms
コンパイル使用メモリ 181,060 KB
実行使用メモリ 9,900 KB
最終ジャッジ日時 2026-10-26 14:25:44
合計ジャッジ時間 6,451 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use itertools::Itertools;
use proconio::{input, marker::Bytes};

fn main() {
    input! {
        mut n: Bytes
    }
    n.iter_mut().for_each(|n| *n -= b'0');

    if let Some(i) = n.iter().position(|&n| !(4..=5).contains(&n)) {
        if n[i] < 4 {
            if let Some(j) = n[..i].iter().rposition(|&n| n == 5) {
                n[j] = 4;
                n[j + 1..].fill(5);
            } else {
                n.fill(5);
                n.pop();
            }
        } else {
            n[i..].fill(5);
        }
    }

    println!("{}", n.iter().join(""));
}
0