結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー 👑 H20H20
提出日時 2023-12-02 16:55:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 721 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 90,112 KB
最終ジャッジ日時 2023-12-02 16:55:36
合計ジャッジ時間 8,790 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 48 ms
65,236 KB
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#めぐる式二分探索
#参考サイト:https://aotamasaki.hatenablog.com/entry/meguru_bisect

def is_ok(a):
    return N*(a+a-N+1)//2<=X

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

T = int(input())
for _ in range(T):
    N,X = map(int,input().split())
    M = meguru_bisect(10**19,0)
    L = list(range(M-N+1,M+1))[::-1]
    ANS = []
    i = 1
    while len(ANS)<N and X>=i:
        ANS.append(i)
        X-=i
        i+=1
    ANS[-1]+=X
    if len(ANS)==N:
        temp = X-sum(L)
        for i in range(temp):
            L[i]+=1
        print(*L)
    else:
        print(-1)
0