結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー 👑 OnjoujiTokiOnjoujiToki
提出日時 2023-12-03 05:41:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,206 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 131,892 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-03 05:41:38
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>

void solve() {
  int n;
  long long x;
  std::cin >> n >> x;
  long long least = (n + 1) * n / 2;
  if (x < least) {
    std::cout << -1 << '\n';
    return;
  }

  long long l = 1, r = x;
  while (l < r) {
    long long mid = (l + r) / 2;
    if ((mid + mid + n - 1) * n / 2 >= x) {
      r = mid;
    } else
      l = mid + 1;
  }
  long long diff = (l + l + n - 1) * n / 2 - x;

  std::vector<long long> ans(n);
  for (int i = n - 1; i >= 0; i--) {
    ans[i] = l++;
  }

  for (int i = n - 1, cnt = 0; i >= 0; i--) {
    cnt++;
    ans[i] -= 1;
    if (cnt == diff) break;
  }
  for (auto& x : ans) std::cout << x << ' ';
  std::cout << '\n';
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int t = 1;
  std::cin >> t;
  while (t--) {
    solve();
  }
}
0