結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー k82bk82b
提出日時 2023-12-02 16:24:17
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 1,181 bytes
コンパイル時間 4,102 ms
コンパイル使用メモリ 199,028 KB
実行使用メモリ 7,636 KB
最終ジャッジ日時 2023-12-02 16:24:25
合計ジャッジ時間 7,293 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std, core.bitop;
string[] _R;
void readM(T)(ref T x) { while (_R.empty) { _R = readln.chomp.split; } x = _R.front.to!T; _R.popFront; }
bool chmin(T)(ref T A, T B) { if (A > B) { A = B; return true; } else { return false; } }
bool chmax(T)(ref T A, T B) { if (A < B) { A = B; return true; } else { return false; } }
int lowerBound(T)(T[] A, T x) { int lo = -1, hi = cast(int)(A.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (A[mid] < x ? lo : hi) = mid; } return hi; }
int upperBound(T)(T[] A, T x) { int lo = -1, hi = cast(int)(A.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (A[mid] > x ? hi : lo) = mid; } return hi; }

void main() {
	int TE;
	TE.readM;
	foreach (_; 0 .. TE) {
		long N, X;
		N.readM;
		X.readM;
		if (N * (N + 1) / 2 > X) {
			writeln(-1);
			continue;
		}
		long lo = N, hi = (10 ^^ 9) * 2;
		while (hi - lo > 1) {
			long mid = lo + hi >> 1;
			(mid * (mid + 1) / 2 - (mid - N) * (mid - N + 1) / 2 <= X ? lo : hi) = mid;
		}
		long[] ans;
		foreach_reverse (i; lo - N + 1 .. lo + 1) {
			ans ~= i;
		}
		for (int i = 0; lo * (lo + 1) / 2 - (lo - N) * (lo - N + 1) / 2 + i < X; ++i) {
			++ans[i];
		}
		writefln("%(%s %)", ans);
	}
}
0