結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー phsplsphspls
提出日時 2022-08-31 23:15:18
言語 Rust
(1.77.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 962 ms
コンパイル使用メモリ 171,516 KB
実行使用メモリ 14,380 KB
最終ジャッジ日時 2024-04-26 05:10:45
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 0 ms
6,940 KB
testcase_02 AC 25 ms
14,364 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 24 ms
14,380 KB
testcase_05 AC 24 ms
14,308 KB
testcase_06 AC 25 ms
14,360 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 17 ms
11,008 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 9 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 6 ms
6,944 KB
testcase_13 AC 5 ms
6,944 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 4 ms
6,944 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 15 ms
9,004 KB
testcase_23 AC 8 ms
6,944 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 17 ms
10,412 KB
testcase_26 AC 5 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut ns = String::new();
    std::io::stdin().read_line(&mut ns).ok();
    let ns: Vec<usize> = ns.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = ns[0];
    let mut s = ns[1];

    let mut result = vec![];
    let mut prev = n;
    while s > 0 {
        let minus = prev.min(s);
        s -= minus;
        prev = minus - 1;
        result.push(minus);
    }
    println!("{}", result.len());
    result.reverse();
    let result: Vec<String> = result.into_iter().map(|v| v.to_string()).collect();
    println!("{}", result.join(" "));
}
0