結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー ntudantuda
提出日時 2022-10-09 02:18:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 184 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 10,672 KB
実行使用メモリ 19,372 KB
最終ジャッジ日時 2023-09-05 07:03:18
合計ジャッジ時間 4,041 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,884 KB
testcase_01 AC 17 ms
7,720 KB
testcase_02 AC 166 ms
19,296 KB
testcase_03 AC 16 ms
7,772 KB
testcase_04 AC 164 ms
19,372 KB
testcase_05 AC 162 ms
19,152 KB
testcase_06 AC 163 ms
19,240 KB
testcase_07 AC 43 ms
9,724 KB
testcase_08 AC 127 ms
16,024 KB
testcase_09 AC 47 ms
8,780 KB
testcase_10 AC 76 ms
12,028 KB
testcase_11 AC 48 ms
9,076 KB
testcase_12 AC 57 ms
10,324 KB
testcase_13 AC 42 ms
10,052 KB
testcase_14 AC 28 ms
9,212 KB
testcase_15 AC 60 ms
9,776 KB
testcase_16 AC 67 ms
10,840 KB
testcase_17 AC 17 ms
7,772 KB
testcase_18 AC 16 ms
7,756 KB
testcase_19 AC 16 ms
7,752 KB
testcase_20 AC 17 ms
7,728 KB
testcase_21 AC 16 ms
7,828 KB
testcase_22 AC 100 ms
14,440 KB
testcase_23 AC 62 ms
11,752 KB
testcase_24 AC 28 ms
9,136 KB
testcase_25 AC 115 ms
15,448 KB
testcase_26 AC 38 ms
10,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, S = map(int, input().split())
tmp = 0
ans = []
for i in reversed(range(1, N + 1)):
    if tmp + i <= S:
        tmp += i
        ans.append(i)
print(len(ans))
print(*reversed(ans))
0