結果

問題 No.2560 A_1 < A_2 < ... < A_N
ユーザー Shogo_KShogo_K
提出日時 2023-12-02 16:22:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 774 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 92,336 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 16:22:52
合計ジャッジ時間 3,363 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 141 ms
6,676 KB
testcase_07 AC 145 ms
6,676 KB
testcase_08 AC 148 ms
6,676 KB
testcase_09 AC 140 ms
6,676 KB
testcase_10 AC 140 ms
6,676 KB
testcase_11 AC 2 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
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#define INF 1e8

struct pair {
  int N, X;
};

int main() {
  int T; 
  std::cin >> T;

  std::vector<pair> array(T);
  for (auto &&e: array) {
    std::cin >> e.N >> e.X;
  }

  for (auto &&test: array) {

    int sum_n = test.N * (test.N + 1) / 2;

    // 論外は弾く
    if (test.X < sum_n) {
      std::cout << -1 << std::endl;
      continue;
    }

    // 並べるだけ並べて、最後に余りをくっつける
    std::vector<int> result(test.N);

    for (int i = 0; i < test.N; i++) {
      result[i] = i + 1;
    }

    result.back() += test.X - sum_n;

    // 出力して終了
    for (auto &&e: result) {
      std::cout << e << " ";
    }
    std::cout << std::endl;
  }
}
0