結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー ikomaikoma
提出日時 2022-08-05 22:03:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 213 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 98,688 KB
最終ジャッジ日時 2024-09-15 18:51:38
合計ジャッジ時間 3,890 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

N,S=map(int,input().split())
ans = []
s = N*(N+1)//2
for i in range(N,0,-1):
    if s-S>=i:
        s-=i
    else:
        ans.append(i)
if len(ans)>0:
    print(len(ans))
    print(*ans[::-1])
else:
    print(-1)
0