結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー shirokumashirokuma
提出日時 2022-08-08 23:56:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 411 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 96,808 KB
最終ジャッジ日時 2023-10-19 11:42:29
合計ジャッジ時間 5,545 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,728 KB
testcase_01 AC 39 ms
51,720 KB
testcase_02 AC 94 ms
96,552 KB
testcase_03 AC 38 ms
53,388 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 92 ms
96,488 KB
testcase_07 AC 54 ms
70,164 KB
testcase_08 AC 81 ms
90,152 KB
testcase_09 AC 54 ms
63,856 KB
testcase_10 AC 70 ms
81,776 KB
testcase_11 AC 53 ms
67,084 KB
testcase_12 AC 58 ms
73,472 KB
testcase_13 AC 57 ms
72,600 KB
testcase_14 AC 53 ms
66,460 KB
testcase_15 AC 55 ms
70,168 KB
testcase_16 AC 58 ms
76,576 KB
testcase_17 AC 41 ms
52,372 KB
testcase_18 AC 41 ms
52,244 KB
testcase_19 AC 42 ms
52,068 KB
testcase_20 AC 44 ms
52,708 KB
testcase_21 AC 44 ms
52,492 KB
testcase_22 WA -
testcase_23 AC 69 ms
81,176 KB
testcase_24 AC 54 ms
65,744 KB
testcase_25 AC 82 ms
89,624 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1915
N, K = map(int, input().split())
if K <= N:
    print(1)
    print(K)
    exit()
if K > N*(N+1)//2:
    print(-1)
    exit()

ans = []
temp = K
for i in range(N, 0, -1):
    temp -= i
    ans.append(i)
    if temp < i - 1:
        if i != 0:
            ans.append(temp)
        ans.reverse()
        print(len(ans))
        print(*ans)
        exit()

ans.reverse()
print(len(ans))
print(*ans)
exit()
0