結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー mymelochanmymelochan
提出日時 2023-12-02 16:00:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,214 ms / 2,000 ms
コード長 1,034 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 96,056 KB
最終ジャッジ日時 2023-12-02 16:00:22
合計ジャッジ時間 9,793 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
55,724 KB
testcase_01 AC 942 ms
87,736 KB
testcase_02 AC 1,109 ms
93,496 KB
testcase_03 AC 935 ms
90,936 KB
testcase_04 AC 1,132 ms
92,728 KB
testcase_05 AC 1,214 ms
96,056 KB
testcase_06 AC 391 ms
79,200 KB
testcase_07 AC 414 ms
79,504 KB
testcase_08 AC 380 ms
79,460 KB
testcase_09 AC 378 ms
79,380 KB
testcase_10 AC 412 ms
79,344 KB
testcase_11 AC 48 ms
65,856 KB
testcase_12 AC 55 ms
68,624 KB
testcase_13 AC 44 ms
63,788 KB
testcase_14 AC 39 ms
55,724 KB
testcase_15 AC 55 ms
68,616 KB
testcase_16 AC 44 ms
63,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations
from math import sin,cos
#from math import isqrt #DO NOT USE PyPy

ipt = sys.stdin.readline
iin = lambda :int(ipt())
lmin = lambda :list(map(int,ipt().split()))

#############################################################

for _ in range(iin()):
    N,X = lmin()

    if N*(N+1)//2 > X:
        print(-1)
        continue

    ans = []

    v = 1<<60
    rem = X
    for i in range(N-1):
        ok = v
        ng = N-1-i
        r = N-i
        while ok-ng > 1:
            cen = (ok+ng)//2
            if (cen+1)*cen//2 - (cen-r+1)*(cen-r)//2 >= rem:
                ok = cen
            else:
                ng = cen
        v = ok-1
        ans.append(ok)
        #print("a",ok,rem)
        rem -= ok

    ans.append(rem)
    print(*ans)
0