結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-02 16:15:07
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 9,091 ms
コンパイル使用メモリ 158,724 KB
実行使用メモリ 180,652 KB
最終ジャッジ日時 2023-12-02 16:15:22
合計ジャッジ時間 13,416 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
32,804 KB
testcase_01 AC 124 ms
52,452 KB
testcase_02 AC 126 ms
59,068 KB
testcase_03 AC 116 ms
56,172 KB
testcase_04 AC 129 ms
60,900 KB
testcase_05 AC 130 ms
60,244 KB
testcase_06 AC 205 ms
62,924 KB
testcase_07 AC 206 ms
63,056 KB
testcase_08 AC 208 ms
62,924 KB
testcase_09 AC 204 ms
62,924 KB
testcase_10 AC 204 ms
62,924 KB
testcase_11 AC 78 ms
32,804 KB
testcase_12 AC 74 ms
33,188 KB
testcase_13 AC 78 ms
33,060 KB
testcase_14 AC 74 ms
32,548 KB
testcase_15 AC 79 ms
33,060 KB
testcase_16 AC 78 ms
180,652 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (102 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new string[t];
        for (var u = 0; u < t; ++u)
        {
            var c = NList;
            var (n, x) = (c[0], c[1]);
            ans[u] = Down(n, x);
        }
        WriteLine(string.Join("\n", ans));
    }
    static string Down(long n, long x)
    {
        if (x < n * (n + 1) / 2) return "-1";
        var ng = 0L;
        var ok = x / n + n;
        while (ok - ng > 1)
        {
            var mid = (ok + ng) / 2;
            if ((mid * 2 - n + 1) * n / 2 >= x) ok = mid;
            else ng = mid;
        }
        var sum = 0L;
        var ans = new long[n];
        for (var i = 0; i < n; ++i)
        {
            ans[i] = ok - i;
            sum += ok - i;
        }
        for (var i = n - 1; i >= 0; --i) if (sum > x)
        {
            --ans[i];
            --sum;
        }
        return string.Join(" ", ans);
    }
}
0