結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー titiatitia
提出日時 2022-08-05 21:23:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 308 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 10,692 KB
実行使用メモリ 27,428 KB
最終ジャッジ日時 2023-10-13 21:45:31
合計ジャッジ時間 4,032 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,808 KB
testcase_01 AC 16 ms
7,908 KB
testcase_02 AC 123 ms
27,340 KB
testcase_03 AC 16 ms
7,856 KB
testcase_04 AC 122 ms
27,428 KB
testcase_05 AC 122 ms
27,268 KB
testcase_06 AC 122 ms
27,236 KB
testcase_07 AC 59 ms
16,612 KB
testcase_08 AC 110 ms
25,756 KB
testcase_09 AC 113 ms
25,244 KB
testcase_10 AC 78 ms
18,296 KB
testcase_11 AC 95 ms
17,512 KB
testcase_12 AC 78 ms
17,796 KB
testcase_13 AC 44 ms
12,840 KB
testcase_14 AC 25 ms
9,588 KB
testcase_15 AC 120 ms
25,244 KB
testcase_16 AC 92 ms
19,376 KB
testcase_17 AC 17 ms
8,196 KB
testcase_18 AC 16 ms
7,736 KB
testcase_19 AC 16 ms
7,808 KB
testcase_20 AC 17 ms
8,236 KB
testcase_21 AC 16 ms
7,912 KB
testcase_22 AC 76 ms
18,412 KB
testcase_23 AC 48 ms
13,336 KB
testcase_24 AC 25 ms
9,340 KB
testcase_25 AC 88 ms
19,756 KB
testcase_26 AC 34 ms
11,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

SET=set(range(1,N+1))
SUM=N*(N+1)//2
MAX=N

while SUM>S:
    if SUM-S>MAX:
        SET.remove(MAX)
        SUM-=MAX
        MAX-=1
    else:
        x=SUM-S
        SET.remove(x)
        SUM-=x
        
print(len(SET))
print(*sorted(SET))
0