結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー Basin-BugBasin-Bug
提出日時 2023-12-02 16:59:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,460 KB
最終ジャッジ日時 2023-12-02 17:00:04
合計ジャッジ時間 4,548 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

T = int(input())

def binary_search(X):
  left = 1
  right = X

  while left + 1 < right:
    mid = (left + right) // 2
    if mid * (mid + 1) // 2 > X:
      right = mid
    elif mid *(mid + 1) // 2 == X:
      return mid
    else:
      left = mid + 1
  
  return left

for i in range(T):
  N, X = map(int, input().split())
  
  ans = []
  ng = False
  for i in range(N - 1):
    num = binary_search(X)
    if num == 0 or (len(ans) > 0 and num >= ans[-1]):
      if not ng:
        print(-1)
      ng = True
    else:
      ans.append(num)
      X -= num
  if not ng:
    if X < ans[-1]:
      ans.append(X)
      print(*ans)
    else:
      print(-1)
0