結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー titiatitia
提出日時 2023-12-17 02:12:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 83,304 KB
最終ジャッジ日時 2023-12-17 02:12:33
合計ジャッジ時間 4,886 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 121 ms
80,236 KB
testcase_02 AC 159 ms
82,476 KB
testcase_03 AC 122 ms
81,152 KB
testcase_04 AC 134 ms
81,944 KB
testcase_05 AC 140 ms
83,304 KB
testcase_06 AC 334 ms
76,452 KB
testcase_07 AC 344 ms
76,472 KB
testcase_08 AC 319 ms
76,800 KB
testcase_09 AC 316 ms
76,708 KB
testcase_10 AC 351 ms
76,452 KB
testcase_11 AC 43 ms
63,924 KB
testcase_12 AC 46 ms
67,128 KB
testcase_13 AC 37 ms
61,844 KB
testcase_14 AC 33 ms
53,972 KB
testcase_15 AC 48 ms
66,956 KB
testcase_16 AC 38 ms
61,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())

for tests in range(T):
    N,X=map(int,input().split())
    ANS=[0]*N

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

    for i in range(N):
        NG=N-i-1
        if i==0:
            OK=10**18
        else:
            OK=ANS[i-1]-1

        while OK>NG+1:
            #print(i,OK,NG)
            mid=(OK+NG)//2

            S=X-mid
            L=N-i-1

            #print(S,mid,i,((mid-1)+(mid-1-(L-1)))*L//2)

            if S<=((mid-1)+(mid-1-(L-1)))*L//2:
                OK=mid
            else:
                NG=mid

        #print("!",OK,NG)

        ANS[i]=OK
        X-=OK

    print(*ANS)
        
0