結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー mkawa2mkawa2
提出日時 2023-12-02 15:58:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 1,496 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 84,880 KB
最終ジャッジ日時 2023-12-02 15:58:05
合計ジャッジ時間 3,865 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 97 ms
81,300 KB
testcase_02 AC 91 ms
83,892 KB
testcase_03 AC 82 ms
83,124 KB
testcase_04 AC 85 ms
84,348 KB
testcase_05 AC 89 ms
84,880 KB
testcase_06 AC 199 ms
77,200 KB
testcase_07 AC 203 ms
77,456 KB
testcase_08 AC 194 ms
77,256 KB
testcase_09 AC 201 ms
77,460 KB
testcase_10 AC 188 ms
77,208 KB
testcase_11 AC 39 ms
53,460 KB
testcase_12 AC 50 ms
65,724 KB
testcase_13 AC 42 ms
61,304 KB
testcase_14 AC 40 ms
60,236 KB
testcase_15 AC 48 ms
65,520 KB
testcase_16 AC 42 ms
61,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = -1-(-1 << 31)
# inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

def solve():
    def binary_search(l, r, minimize):
        if minimize: l -= 1
        else: r += 1
        while l+1 < r:
            m = (l+r)//2
            if ok(m) ^ minimize: l = m
            else: r = m
        if minimize: return r
        return l

    def ok(m):
        return n-1+m<a[-1]-m*(n-1)

    n,x=LI()
    if n==1:
        print(x)
        return 
    a=list(range(1,n))
    a.append(x-n*(n-1)//2)
    if a[-2]>=a[-1]:
        print(-1)
    else:
        d=binary_search(0,x,False)
        a[-1]-=d*(n-1)
        for i in range(n-1):a[i]+=d
        d=a[-1]-(a[-2]+2)
        if d>0:
            a[-1]-=d
            for i in range(n-2,n-2-d,-1):a[i]+=1
        print(*a[::-1])

for _ in range(II()):solve()
0