結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー achapiachapi
提出日時 2023-12-02 15:46:59
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 204,280 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-26 19:16:52
合計ジャッジ時間 4,651 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int T;
	cin >> T;
	while (T--){
		int N;
		long long X;
		cin >> N >> X;
		if ((long long) N * (N + 1) / 2 > X){
			cout << -1 << endl;
			continue;
		}
		vector<long long> ans(N);
		iota(ans.begin(), ans.end(), 1);
		X -= (long long) N * (N + 1) / 2;
		reverse(ans.begin(), ans.end());
		for (int i = 0; i < N; i++){
			ans[i] += X / N;
		}
		X %= N;
		for (int i = 0; i < X; i++){
			ans[i]++;
		}
		for (int i = 0; i < N; i++){
			cout << ans[i];
			if (i + 1 < N){
				cout << ' ';
			}
		}
		cout << endl;
	}
}
0