結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー flippergo
提出日時 2024-12-27 08:25:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 86,912 KB
最終ジャッジ日時 2024-12-27 08:25:55
合計ジャッジ時間 3,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

N,S = map(int,input().split())
cnt = 0
for i in range(N,0,-1):
    if cnt+i<=S:
        cnt += i
        ind = i-1
    else:
        ind = i
        break

if cnt==S:
    A = list(range(ind+1,N+1))
    print(N-ind)
else:
    A = list(range(ind+1,N+1))
    A.insert(0,S-cnt)
    print(N-ind+1)
print(*A)
0