結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー hirakuhiraku
提出日時 2022-08-05 21:30:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 2,278 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 99,904 KB
最終ジャッジ日時 2023-10-13 22:00:01
合計ジャッジ時間 5,097 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,408 KB
testcase_01 AC 74 ms
71,252 KB
testcase_02 AC 121 ms
98,064 KB
testcase_03 AC 70 ms
71,136 KB
testcase_04 AC 121 ms
98,008 KB
testcase_05 AC 122 ms
98,288 KB
testcase_06 AC 123 ms
98,328 KB
testcase_07 AC 99 ms
84,620 KB
testcase_08 AC 122 ms
95,676 KB
testcase_09 AC 117 ms
98,928 KB
testcase_10 AC 110 ms
88,832 KB
testcase_11 AC 110 ms
95,576 KB
testcase_12 AC 108 ms
88,716 KB
testcase_13 AC 96 ms
81,364 KB
testcase_14 AC 84 ms
77,376 KB
testcase_15 AC 118 ms
99,904 KB
testcase_16 AC 112 ms
92,548 KB
testcase_17 AC 81 ms
76,568 KB
testcase_18 AC 73 ms
71,396 KB
testcase_19 AC 74 ms
71,456 KB
testcase_20 AC 81 ms
76,572 KB
testcase_21 AC 76 ms
75,480 KB
testcase_22 AC 103 ms
88,436 KB
testcase_23 AC 94 ms
82,704 KB
testcase_24 AC 83 ms
77,156 KB
testcase_25 AC 109 ms
91,424 KB
testcase_26 AC 86 ms
78,612 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