結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
コンテスト
ユーザー LyricalMaestro
提出日時 2026-11-15 22:45:32
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 65 ms / 2,000 ms
+ 379µs
コード長 542 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 474 ms
コンパイル使用メモリ 64,328 KB
実行使用メモリ 88,952 KB
最終ジャッジ日時 2026-11-15 22:45:37
合計ジャッジ時間 4,753 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/2028

def main():
    N, S = map(int, input().split())

    total = (N * (N + 1)) // 2
    a_set = {i + 1 for i in range(N)}
    for n in reversed(range(1, N + 1)):
        d = total - S
        if d == 0:
            break
        elif d <= n:
            total -= d
            a_set.remove(d)
        else:
            total -= n
            a_set.remove(n)
    a_list = list(a_set)
    a_list.sort()

    print(len(a_list))
    print(" ".join(map(str, a_list)))



if __name__ == "__main__":
    main()
0