結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー wattaiheiwattaihei
提出日時 2022-08-05 22:10:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 274 bytes
コンパイル時間 1,191 ms
コンパイル使用メモリ 86,636 KB
実行使用メモリ 99,844 KB
最終ジャッジ日時 2023-10-13 23:15:50
合計ジャッジ時間 5,768 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,056 KB
testcase_01 AC 72 ms
71,072 KB
testcase_02 AC 124 ms
99,832 KB
testcase_03 AC 71 ms
71,368 KB
testcase_04 AC 122 ms
99,828 KB
testcase_05 AC 122 ms
99,744 KB
testcase_06 AC 126 ms
99,844 KB
testcase_07 AC 87 ms
78,752 KB
testcase_08 AC 112 ms
93,036 KB
testcase_09 AC 83 ms
76,404 KB
testcase_10 AC 97 ms
83,968 KB
testcase_11 AC 84 ms
77,540 KB
testcase_12 AC 87 ms
80,008 KB
testcase_13 AC 86 ms
79,080 KB
testcase_14 AC 83 ms
76,876 KB
testcase_15 AC 87 ms
78,660 KB
testcase_16 AC 93 ms
82,212 KB
testcase_17 AC 76 ms
75,716 KB
testcase_18 AC 71 ms
71,388 KB
testcase_19 AC 71 ms
71,436 KB
testcase_20 AC 76 ms
75,628 KB
testcase_21 AC 71 ms
71,104 KB
testcase_22 AC 106 ms
89,184 KB
testcase_23 AC 93 ms
83,348 KB
testcase_24 AC 82 ms
77,208 KB
testcase_25 AC 108 ms
92,612 KB
testcase_26 AC 86 ms
79,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, S = map(int, input().rstrip().split())

if not 1 <= S <= N*(N+1)//2:
    print(-1)
else:
    remain = S
    ans = []
    for i in range(N, 0, -1):
        if i <= remain:
            remain -= i
            ans.append(i)
        
    print(len(ans))
    print(*ans[::-1])
0