結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー 👑 kakel-sankakel-san
提出日時 2022-08-05 21:48:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 1,796 ms
コンパイル使用メモリ 67,924 KB
実行使用メモリ 36,484 KB
最終ジャッジ日時 2023-10-13 22:29:10
合計ジャッジ時間 6,096 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
23,820 KB
testcase_01 AC 64 ms
21,696 KB
testcase_02 AC 107 ms
36,432 KB
testcase_03 AC 64 ms
21,804 KB
testcase_04 AC 108 ms
36,484 KB
testcase_05 AC 107 ms
36,300 KB
testcase_06 AC 107 ms
36,316 KB
testcase_07 AC 70 ms
22,480 KB
testcase_08 AC 97 ms
34,668 KB
testcase_09 AC 65 ms
19,692 KB
testcase_10 AC 81 ms
26,608 KB
testcase_11 AC 69 ms
22,392 KB
testcase_12 AC 73 ms
23,440 KB
testcase_13 AC 73 ms
25,028 KB
testcase_14 AC 68 ms
21,896 KB
testcase_15 AC 71 ms
24,600 KB
testcase_16 AC 76 ms
25,664 KB
testcase_17 AC 64 ms
21,820 KB
testcase_18 AC 65 ms
21,848 KB
testcase_19 AC 64 ms
21,900 KB
testcase_20 AC 66 ms
23,804 KB
testcase_21 AC 66 ms
21,772 KB
testcase_22 AC 90 ms
27,848 KB
testcase_23 AC 78 ms
25,828 KB
testcase_24 AC 68 ms
21,992 KB
testcase_25 AC 94 ms
36,092 KB
testcase_26 AC 70 ms
22,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        var c = NList;
        var (n, s) = (c[0], c[1]);
        var list = new List<long>();
        for (var i = n; i > 0; --i)
        {
            if (s >= i)
            {
                list.Add(i);
                s -= i;
            }
        }
        list.Reverse();
        WriteLine(list.Count);
        WriteLine(string.Join(" ", list));
    }
}
0