結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー achapiachapi
提出日時 2022-08-05 21:27:57
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 205 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 101,424 KB
最終ジャッジ日時 2023-10-13 21:53:15
合計ジャッジ時間 4,921 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,296 KB
testcase_01 AC 70 ms
71,544 KB
testcase_02 AC 125 ms
101,396 KB
testcase_03 AC 72 ms
71,216 KB
testcase_04 AC 123 ms
101,328 KB
testcase_05 AC 122 ms
101,060 KB
testcase_06 AC 125 ms
101,424 KB
testcase_07 AC 91 ms
79,552 KB
testcase_08 AC 115 ms
94,296 KB
testcase_09 AC 89 ms
79,092 KB
testcase_10 AC 100 ms
85,584 KB
testcase_11 AC 91 ms
79,812 KB
testcase_12 AC 96 ms
82,384 KB
testcase_13 AC 91 ms
79,596 KB
testcase_14 AC 85 ms
77,012 KB
testcase_15 AC 95 ms
81,104 KB
testcase_16 AC 98 ms
84,268 KB
testcase_17 AC 76 ms
76,136 KB
testcase_18 AC 71 ms
71,492 KB
testcase_19 AC 72 ms
71,496 KB
testcase_20 AC 78 ms
76,268 KB
testcase_21 AC 71 ms
71,416 KB
testcase_22 AC 106 ms
90,024 KB
testcase_23 AC 96 ms
83,408 KB
testcase_24 AC 85 ms
77,252 KB
testcase_25 AC 109 ms
93,336 KB
testcase_26 AC 85 ms
78,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,s=map(int,input().split())
a=[*range(1,n+1)]
ans=[]
while s!=0 or len(a)!=0:
    c=a.pop()
    if s-c>=0:
        s-=c
        ans.append(c)
if s!=0:exit(print(-1))
print(len(ans))
ans.sort()
print(*ans)
0