結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー Rusty
提出日時 2023-12-02 15:59:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 449 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 89,600 KB
最終ジャッジ日時 2024-09-26 19:38:17
合計ジャッジ時間 5,352 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

def sub(l,n):
    return (l + l - (n - 1))*n//2

t = int(input())

for case in range(t):
    n,x = map(int,input().split())
    if x < n*(n+1)//2:
        print(-1)
    else:
        ans = [10**19]
        for i in range(n-1):
            left = 0
            right = ans[-1]-1
            while left + 1 < right:
                mid = (left + right)//2
                if sub(mid - 1, n - 1 - i) < x - mid:
                    left = mid
                else:
                    right = mid
            x -= right
            ans.append(right)
        
        ans.append(x)
        print(*ans[1:])
0