結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー ああいいああいい
提出日時 2022-08-07 16:19:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 435 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 81,548 KB
実行使用メモリ 98,004 KB
最終ジャッジ日時 2023-10-17 11:16:21
合計ジャッジ時間 4,601 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 37 ms
53,292 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 90 ms
98,004 KB
testcase_07 AC 55 ms
70,340 KB
testcase_08 AC 80 ms
91,140 KB
testcase_09 AC 50 ms
64,228 KB
testcase_10 AC 67 ms
82,428 KB
testcase_11 AC 51 ms
67,188 KB
testcase_12 AC 56 ms
73,752 KB
testcase_13 AC 55 ms
72,808 KB
testcase_14 AC 51 ms
66,408 KB
testcase_15 AC 53 ms
70,340 KB
testcase_16 AC 58 ms
76,932 KB
testcase_17 AC 39 ms
53,292 KB
testcase_18 AC 39 ms
53,292 KB
testcase_19 AC 38 ms
53,292 KB
testcase_20 AC 40 ms
53,292 KB
testcase_21 AC 39 ms
53,292 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,S = map(int,input().split())

import sys
if S <= N:
    print(S)
    exit()
M = N * (N + 1) // 2
if M - S <= N:
    ans = []
    for i in range(1,N + 1):
        if i != M - S:
            ans.append(i)
    print(*ans)
    exit()
    
tmp = 0
ans = []
for i in range(N,0,-1):
    if tmp + i <= S:
        ans.append(i)
        tmp += i
    else:
        break
if S - tmp > 0:
    ans.append(S - tmp)
print(len(ans))
print(*ans[::-1])
0