結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー lloyzlloyz
提出日時 2022-08-05 21:56:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 415 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 10,536 KB
実行使用メモリ 19,288 KB
最終ジャッジ日時 2023-10-13 22:42:17
合計ジャッジ時間 4,915 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,756 KB
testcase_01 AC 14 ms
7,772 KB
testcase_02 AC 193 ms
19,288 KB
testcase_03 RE -
testcase_04 AC 197 ms
19,216 KB
testcase_05 AC 196 ms
19,140 KB
testcase_06 AC 196 ms
19,224 KB
testcase_07 AC 69 ms
11,424 KB
testcase_08 AC 168 ms
17,616 KB
testcase_09 AC 70 ms
11,612 KB
testcase_10 AC 111 ms
14,092 KB
testcase_11 AC 82 ms
12,244 KB
testcase_12 AC 94 ms
13,012 KB
testcase_13 AC 57 ms
10,908 KB
testcase_14 AC 30 ms
9,272 KB
testcase_15 AC 104 ms
13,836 KB
testcase_16 AC 116 ms
14,368 KB
testcase_17 AC 16 ms
7,784 KB
testcase_18 AC 16 ms
7,760 KB
testcase_19 AC 15 ms
7,756 KB
testcase_20 AC 16 ms
8,200 KB
testcase_21 AC 15 ms
7,896 KB
testcase_22 AC 119 ms
14,436 KB
testcase_23 AC 72 ms
11,416 KB
testcase_24 AC 31 ms
8,996 KB
testcase_25 AC 140 ms
15,808 KB
testcase_26 AC 45 ms
10,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ANS = []
res = 0
for i in range(1, n + 1):
    res += i
    ANS.append(i)
    if i < s - res <= n:
        ANS.append(s - res)
        break
    elif s - res <= i:
        j = i - (s - res)
        ANS.pop(j)
        ANS.append(s - res + j + 1)
        break
    elif s - res == 0:
        break

#print(ANS)
if sum(ANS) != s:
    print(-1)
    exit()

print(len(ANS))
print(*ANS)
0