結果
| 問題 | No.2567 A_1 > A_2 > ... > A_N | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2023-12-04 01:24:31 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 55 ms / 2,000 ms | 
| コード長 | 947 bytes | 
| コンパイル時間 | 718 ms | 
| コンパイル使用メモリ | 41,928 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-26 22:36:44 | 
| 合計ジャッジ時間 | 2,635 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 16 | 
ソースコード
/* -*- coding: utf-8 -*-
 *
 * 2567.cc:  No.2567 A_1 > A_2 > ... > A_N - yukicoder
 */
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
const long long MAX_X = 1000000000000000000LL;
/* typedef */
typedef long long ll;
/* global variables */
/* subroutines */
inline ll sigma(ll a, int n) {
  return (a - n) * n + (ll)n * (n + 1) / 2;
}
/* main */
int main() {
  int tn;
  scanf("%d", &tn);
  while (tn--) {
    int n;
    ll x;
    scanf("%d%lld", &n, &x);
    if (sigma(n, n) > x) { puts("-1"); continue; }
    ll b0 = n - 1, b1 = MAX_X * 2 / n;
    while (b0 + 1 < b1) {
      ll b = (b0 + b1) / 2;
      if (sigma(b, n) >= x) b1 = b;
      else b0 = b;
    }
    //printf("b1=%d\n", b1);
    ll ai = b1;
    for (int i = 0; i < n; i++) {
      while (sigma(ai - 1, n - i) >= x) ai--;
      x -= ai;
      printf("%lld%c", ai, (i + 1 < n) ? ' ' : '\n');
    }
  }
  return 0;
}
            
            
            
        