結果

問題 No.2560 A_1 < A_2 < ... < A_N
ユーザー toshiconnertoshiconner
提出日時 2023-12-02 14:55:05
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 99,312 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 14:55:11
合計ジャッジ時間 3,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 19 ms
6,548 KB
testcase_02 AC 22 ms
6,548 KB
testcase_03 AC 19 ms
6,548 KB
testcase_04 AC 22 ms
6,676 KB
testcase_05 AC 23 ms
6,676 KB
testcase_06 AC 147 ms
6,676 KB
testcase_07 AC 147 ms
6,676 KB
testcase_08 AC 145 ms
6,676 KB
testcase_09 AC 145 ms
6,676 KB
testcase_10 AC 147 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<vector>
#include<ranges>
using namespace std;
using ll = long long;

int main() {
    int T; cin >> T;
    while(T--) {
        int N; ll X; cin >> N >> X;
        vector<ll> ans {0};

        auto res = X;
        auto success = true;
        for(int i = 1; i <= (N - 1); ++i) {
            if (res < i) {
                success = false;
                break;
            }
            ans.push_back(i);
            res -= i;
        }

        if (res <= ans.back()) {
            success = false;
        }
        ans.push_back(res);

        if (success) {
            for(int i = 1; i <= N; ++i) {
                cout << ans[i] << " ";
            }
            cout << endl;
        } else {
            cout << -1 << endl;
        }
    }
}
0