結果

問題 No.1114 足し算盆に返らず
ユーザー phsplsphspls
提出日時 2020-07-17 21:42:04
言語 Rust
(1.72.1)
結果
AC  
実行時間 1,080 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 1,254 ms
コンパイル使用メモリ 149,844 KB
実行使用メモリ 5,416 KB
最終ジャッジ日時 2023-08-20 00:18:08
合計ジャッジ時間 20,305 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,080 ms
5,400 KB
testcase_01 AC 1,079 ms
5,416 KB
testcase_02 AC 1,079 ms
5,404 KB
testcase_03 AC 647 ms
4,568 KB
testcase_04 AC 950 ms
5,044 KB
testcase_05 AC 279 ms
4,380 KB
testcase_06 AC 976 ms
5,048 KB
testcase_07 AC 969 ms
5,084 KB
testcase_08 AC 380 ms
4,380 KB
testcase_09 AC 270 ms
4,384 KB
testcase_10 AC 366 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 514 ms
4,380 KB
testcase_13 AC 1,059 ms
5,400 KB
testcase_14 AC 27 ms
4,380 KB
testcase_15 AC 180 ms
4,380 KB
testcase_16 AC 307 ms
4,384 KB
testcase_17 AC 534 ms
4,380 KB
testcase_18 AC 105 ms
4,384 KB
testcase_19 AC 200 ms
4,376 KB
testcase_20 AC 1,057 ms
5,404 KB
testcase_21 AC 169 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();

    let mut dp: Vec<bool> = vec![false; n+1];
    let mut result: Vec<usize> = vec![];
    for i in 1..=n {
        if dp[i] { continue; }
        for p in result.iter() {
            if *p + i <= n {
                dp[*p+i] = true;
            }
        }
        dp[i] = true;
        if 2*i <= n {
            dp[2*i] = true;
        }
        result.push(i);
    }
    println!("{}", result.iter().map(|&i| i.to_string()).collect::<Vec<String>>().join(" "));
}
0