結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 39 ms
53,292 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 93 ms
98,008 KB
testcase_07 AC 55 ms
70,340 KB
testcase_08 AC 84 ms
91,144 KB
testcase_09 AC 51 ms
64,228 KB
testcase_10 AC 67 ms
82,432 KB
testcase_11 AC 52 ms
67,188 KB
testcase_12 AC 58 ms
73,752 KB
testcase_13 AC 56 ms
72,808 KB
testcase_14 AC 51 ms
66,408 KB
testcase_15 AC 55 ms
70,340 KB
testcase_16 AC 59 ms
76,932 KB
testcase_17 AC 40 ms
53,292 KB
testcase_18 AC 40 ms
53,292 KB
testcase_19 AC 39 ms
53,292 KB
testcase_20 AC 41 ms
53,292 KB
testcase_21 AC 40 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