結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー hirakuhiraku
提出日時 2022-08-05 21:27:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 10,664 KB
実行使用メモリ 20,488 KB
最終ジャッジ日時 2023-10-14 03:49:28
合計ジャッジ時間 4,110 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,916 KB
testcase_01 AC 16 ms
7,760 KB
testcase_02 AC 131 ms
19,256 KB
testcase_03 AC 16 ms
7,828 KB
testcase_04 AC 132 ms
19,292 KB
testcase_05 AC 133 ms
19,304 KB
testcase_06 AC 132 ms
19,364 KB
testcase_07 AC 59 ms
12,608 KB
testcase_08 AC 118 ms
17,816 KB
testcase_09 AC 95 ms
19,184 KB
testcase_10 AC 83 ms
14,888 KB
testcase_11 AC 87 ms
16,648 KB
testcase_12 AC 79 ms
15,860 KB
testcase_13 AC 46 ms
11,296 KB
testcase_14 AC 27 ms
9,100 KB
testcase_15 AC 111 ms
20,488 KB
testcase_16 AC 95 ms
18,044 KB
testcase_17 AC 17 ms
8,240 KB
testcase_18 AC 16 ms
7,844 KB
testcase_19 AC 16 ms
7,804 KB
testcase_20 AC 17 ms
8,428 KB
testcase_21 AC 16 ms
7,852 KB
testcase_22 AC 82 ms
14,420 KB
testcase_23 AC 51 ms
11,632 KB
testcase_24 AC 26 ms
9,000 KB
testcase_25 AC 95 ms
15,812 KB
testcase_26 AC 36 ms
9,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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