結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー kokatsukokatsu
提出日時 2022-08-05 21:24:43
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 206,740 KB
実行使用メモリ 5,912 KB
最終ジャッジ日時 2023-09-04 18:01:31
合計ジャッジ時間 4,508 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 61 ms
4,996 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 60 ms
5,912 KB
testcase_05 AC 60 ms
4,824 KB
testcase_06 AC 61 ms
4,816 KB
testcase_07 AC 10 ms
4,376 KB
testcase_08 AC 45 ms
4,604 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 22 ms
4,380 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 14 ms
4,380 KB
testcase_13 AC 11 ms
4,380 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 18 ms
5,528 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 35 ms
5,660 KB
testcase_23 AC 20 ms
4,380 KB
testcase_24 AC 7 ms
4,376 KB
testcase_25 AC 41 ms
5,644 KB
testcase_26 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    long N, S;
    readf("%d %d\n", N, S);

    long[] res;
    foreach_reverse (i; 1 .. N+1) {
        if (S < i) continue;

        res ~= i;
        S -= i;
    }

    if (S > 0) {
        writeln(-1);
        return;
    }

    res.reverse;

    res.length.writeln;
    writefln("%(%s %)", res);
}
0