結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー evimaevima
提出日時 2023-12-02 14:58:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 392 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 88,244 KB
最終ジャッジ日時 2023-12-02 14:58:35
合計ジャッジ時間 4,774 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 126 ms
83,748 KB
testcase_02 AC 128 ms
85,840 KB
testcase_03 AC 114 ms
84,836 KB
testcase_04 AC 132 ms
88,244 KB
testcase_05 AC 137 ms
88,056 KB
testcase_06 AC 343 ms
76,808 KB
testcase_07 AC 344 ms
76,808 KB
testcase_08 AC 392 ms
76,800 KB
testcase_09 AC 342 ms
77,060 KB
testcase_10 AC 356 ms
76,804 KB
testcase_11 AC 43 ms
59,068 KB
testcase_12 AC 50 ms
64,328 KB
testcase_13 AC 44 ms
59,368 KB
testcase_14 AC 38 ms
53,460 KB
testcase_15 AC 50 ms
64,328 KB
testcase_16 AC 46 ms
59,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve_one():
    N, X = map(int, input().split())
    mi = N * (N + 1) // 2
    if X < mi:
        print(-1)
        return
    ans = []
    s = 0
    prev_hi = X + 1
    for i in range(N):
        rest = N - i
        lo, hi = N - i - 1, prev_hi - 1
        while lo + 1 < hi:
            mi = (lo + hi) // 2
            t = (mi + (mi - rest + 1)) * rest // 2
            if s + t >= X:
                hi = mi
            else:
                lo = mi
        ans.append(hi)
        prev_hi = hi
        s += hi
    print(*ans)
            

if __name__ == "__main__":
    T = int(input())
    for i in range(1, T + 1):
        solve_one()
0