結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
コンテスト
ユーザー hiraku
提出日時 2022-08-05 21:27:06
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 312 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 679 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 26,012 KB
最終ジャッジ日時 2026-04-05 03:05:18
合計ジャッジ時間 5,690 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n, s = map(int, input().split())

if s > (1 + n) * n // 2:
    print(-1)
else:
    nouse = set()
    r = (1 + n) * n // 2 - s
    for i in range(n, 0, -1):
        if i <= r:
            nouse.add(i)
            r -= i
    ans = [i for i in range(1, n + 1) if i not in nouse]
    print(len(ans))
    print(*ans)
0