結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー shirokumashirokuma
提出日時 2022-08-08 23:53:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 375 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 81,660 KB
実行使用メモリ 96,792 KB
最終ジャッジ日時 2023-10-19 11:40:06
合計ジャッジ時間 4,461 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,432 KB
testcase_01 AC 40 ms
53,432 KB
testcase_02 AC 95 ms
96,764 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 93 ms
96,520 KB
testcase_07 AC 56 ms
70,204 KB
testcase_08 AC 85 ms
90,184 KB
testcase_09 AC 51 ms
64,320 KB
testcase_10 AC 68 ms
82,000 KB
testcase_11 AC 53 ms
67,124 KB
testcase_12 AC 59 ms
73,512 KB
testcase_13 AC 56 ms
72,640 KB
testcase_14 AC 54 ms
66,500 KB
testcase_15 AC 56 ms
70,208 KB
testcase_16 AC 60 ms
76,616 KB
testcase_17 AC 41 ms
53,436 KB
testcase_18 AC 40 ms
53,436 KB
testcase_19 AC 40 ms
53,436 KB
testcase_20 AC 40 ms
53,436 KB
testcase_21 AC 40 ms
53,436 KB
testcase_22 WA -
testcase_23 AC 66 ms
81,208 KB
testcase_24 AC 53 ms
66,904 KB
testcase_25 AC 81 ms
89,656 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1915
N, K = map(int, input().split())
if K <= N:
    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:
        ans.append(temp)
        ans.reverse()
        print(len(ans))
        print(*ans)
        exit()

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