結果

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

ソースコード

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