結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー tnakao0123tnakao0123
提出日時 2023-12-04 01:15:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 893 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 41,792 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-04 01:15:38
合計ジャッジ時間 3,527 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- 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;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

ll sigma(int n) { return (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) > x) { puts("-1"); continue; }

    int b0 = n - 1, b1 = 2000000000;
    while (b0 + 1 < b1) {
      int b = ((ll)b0 + b1) / 2;
      if (sigma(b) - sigma(b - n) >= x) b1 = b;
      else b0 = b;
    }
    //printf("b1=%d\n", b1);

    for (int i = 0, ai = b1; i < n; i++) {
      while (sigma(ai - 1) - sigma(ai - 1 - (n - i)) >= x) ai--;
      x -= ai;
      printf("%d%c", ai, (i + 1 < n) ? ' ' : '\n');
    }
  }

  return 0;
}
0