結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー KemtyKemty
提出日時 2023-12-02 16:12:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 466 ms / 2,000 ms
コード長 1,128 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 100,012 KB
最終ジャッジ日時 2023-12-02 16:12:06
合計ジャッジ時間 6,492 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
79,956 KB
testcase_01 AC 409 ms
92,648 KB
testcase_02 AC 429 ms
96,696 KB
testcase_03 AC 393 ms
94,420 KB
testcase_04 AC 463 ms
95,956 KB
testcase_05 AC 466 ms
100,012 KB
testcase_06 AC 284 ms
82,304 KB
testcase_07 AC 304 ms
82,312 KB
testcase_08 AC 284 ms
82,304 KB
testcase_09 AC 276 ms
82,268 KB
testcase_10 AC 294 ms
82,292 KB
testcase_11 AC 99 ms
80,468 KB
testcase_12 AC 110 ms
81,108 KB
testcase_13 AC 104 ms
80,596 KB
testcase_14 AC 91 ms
80,468 KB
testcase_15 AC 107 ms
81,108 KB
testcase_16 AC 103 ms
80,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
import copy
from itertools import combinations, permutations, product, accumulate, groupby, chain
from heapq import heapify, heappop, heappush
import math
import bisect
from pprint import pprint
from random import randint
import sys
# sys.setrecursionlimit(700000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
mod2 = 998244353
def ceil_div(x, y): return -(-x//y)

################################################


def solve():
    def sum_range(n, s):
        return n*(n+1)//2 + n*(s-1)
    def judge(s):
        return acc + sum_range(N-i, s) <= X
    N, X = map(int, input().split())
    ans = []
    low = 0
    acc = 0
    for i in range(N-1):
        ok, ng = low, 10**18+1
        while(abs(ok-ng)>1):
            mid = (ok+ng)//2
            if judge(mid):
                ok = mid
            else:
                ng = mid
        if ok == low:
            return [-1]
        ans.append(ok)
        low = ok
        acc += ok
    ans.append(X-acc)
    return ans[::-1]

T = int(input())
for _ in range(T):
    print(*solve())
0