結果

問題 No.2560 A_1 < A_2 < ... < A_N
ユーザー bluemeganebluemegane
提出日時 2023-12-02 16:23:54
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 8,576 ms
コンパイル使用メモリ 156,792 KB
実行使用メモリ 180,180 KB
最終ジャッジ日時 2023-12-02 16:24:07
合計ジャッジ時間 12,609 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
32,804 KB
testcase_01 AC 94 ms
41,764 KB
testcase_02 AC 88 ms
41,764 KB
testcase_03 AC 89 ms
43,044 KB
testcase_04 AC 94 ms
43,556 KB
testcase_05 AC 92 ms
42,916 KB
testcase_06 AC 327 ms
47,524 KB
testcase_07 AC 309 ms
47,652 KB
testcase_08 AC 305 ms
47,652 KB
testcase_09 AC 320 ms
47,524 KB
testcase_10 AC 305 ms
47,524 KB
testcase_11 AC 71 ms
32,932 KB
testcase_12 AC 70 ms
33,060 KB
testcase_13 AC 72 ms
32,932 KB
testcase_14 AC 69 ms
32,932 KB
testcase_15 AC 68 ms
180,180 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (94 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.Linq;
using System;

public class Hello
{
    static void Main()
    {
        var T = int.Parse(Console.ReadLine().Trim());
        while (T-- > 0)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = long.Parse(line[0]);
            var x = long.Parse(line[1]);
            getAns(n, x);
        }
    }
    static void getAns(long n, long x)
    {
        var sn = n * (n + 1) / 2;
        if (sn > x) { Console.WriteLine(-1); return; }
        if (sn == x) Console.WriteLine(string.Join(" ", Enumerable.Range(1, (int)n)));
        else
        {
            var sn1 = n * (n - 1) / 2;
            Console.Write(string.Join(" ", Enumerable.Range(1, (int)n - 1)));
            Console.WriteLine(" {0}", x - sn1);
        }
    }
}
0