提出 #16055536


ソースコード 拡げる

use std::cmp::max;

fn main() {
    let k: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut ans: Vec<i8> = Vec::new();
    for _ in 0..k {
        let mut i = 0;
        while i <= ans.len() {
            if i == ans.len() {
                ans.push(1);
                break;
            } else if ans[i] < 9 {
                if i + 1 == ans.len() || (ans[i] + 1 - ans[i + 1]).abs() <= 1 {
                    ans[i] += 1;
                    break;
                }
            }
            i += 1;
        }
        for j in (0..i).rev() {
            ans[j] = max(0, ans[j + 1] - 1);
        }
    }
    
    let ans = ans.iter().rev().map(|x| x.to_string()).collect::<Vec<_>>().join("");
    println!("{}", ans);
}

提出情報

提出日時
問題 D - Lunlun Number
ユーザ Strorkis
言語 Rust (1.42.0)
得点 400
コード長 866 Byte
結果 AC
実行時間 5 ms
メモリ 2120 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 4
AC × 27
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All etc_01.txt, etc_02.txt, etc_03.txt, etc_04.txt, etc_05.txt, etc_06.txt, etc_07.txt, etc_08.txt, etc_09.txt, etc_10.txt, etc_11.txt, etc_12.txt, etc_13.txt, etc_14.txt, etc_15.txt, etc_16.txt, etc_17.txt, etc_18.txt, rand_01.txt, rand_02.txt, rand_03.txt, rand_04.txt, rand_05.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
ケース名 結果 実行時間 メモリ
etc_01.txt AC 5 ms 1992 KiB
etc_02.txt AC 1 ms 2016 KiB
etc_03.txt AC 2 ms 2080 KiB
etc_04.txt AC 2 ms 2088 KiB
etc_05.txt AC 2 ms 1984 KiB
etc_06.txt AC 2 ms 2040 KiB
etc_07.txt AC 1 ms 2120 KiB
etc_08.txt AC 1 ms 1972 KiB
etc_09.txt AC 2 ms 2076 KiB
etc_10.txt AC 1 ms 2064 KiB
etc_11.txt AC 2 ms 2008 KiB
etc_12.txt AC 2 ms 2056 KiB
etc_13.txt AC 1 ms 2032 KiB
etc_14.txt AC 1 ms 1976 KiB
etc_15.txt AC 1 ms 2032 KiB
etc_16.txt AC 2 ms 2012 KiB
etc_17.txt AC 2 ms 2092 KiB
etc_18.txt AC 2 ms 2100 KiB
rand_01.txt AC 3 ms 2028 KiB
rand_02.txt AC 4 ms 1952 KiB
rand_03.txt AC 2 ms 1988 KiB
rand_04.txt AC 2 ms 2036 KiB
rand_05.txt AC 2 ms 1896 KiB
sample_01.txt AC 1 ms 2036 KiB
sample_02.txt AC 2 ms 1888 KiB
sample_03.txt AC 1 ms 2032 KiB
sample_04.txt AC 2 ms 1996 KiB