結果

問題 No.2142 Segment Zero
ユーザー 👑 kakel-sankakel-san
提出日時 2023-09-17 20:05:17
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 2,149 ms
コンパイル使用メモリ 65,784 KB
実行使用メモリ 68,060 KB
最終ジャッジ日時 2023-09-17 20:05:29
合計ジャッジ時間 10,547 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
24,824 KB
testcase_01 AC 314 ms
68,060 KB
testcase_02 AC 63 ms
22,656 KB
testcase_03 AC 62 ms
20,732 KB
testcase_04 AC 327 ms
64,960 KB
testcase_05 AC 317 ms
67,060 KB
testcase_06 AC 64 ms
24,852 KB
testcase_07 AC 112 ms
32,388 KB
testcase_08 AC 320 ms
64,940 KB
testcase_09 AC 204 ms
51,192 KB
testcase_10 AC 316 ms
65,160 KB
testcase_11 AC 317 ms
67,160 KB
testcase_12 AC 305 ms
67,072 KB
testcase_13 AC 305 ms
64,984 KB
testcase_14 AC 294 ms
65,004 KB
testcase_15 AC 307 ms
66,992 KB
testcase_16 AC 307 ms
66,096 KB
testcase_17 AC 276 ms
65,400 KB
testcase_18 AC 69 ms
25,612 KB
testcase_19 AC 84 ms
27,864 KB
testcase_20 AC 177 ms
50,064 KB
testcase_21 AC 147 ms
46,980 KB
testcase_22 AC 234 ms
61,020 KB
testcase_23 AC 96 ms
34,332 KB
testcase_24 AC 114 ms
36,404 KB
testcase_25 AC 96 ms
35,480 KB
testcase_26 AC 176 ms
48,040 KB
testcase_27 AC 112 ms
36,400 KB
testcase_28 AC 151 ms
49,016 KB
testcase_29 AC 175 ms
46,960 KB
testcase_30 AC 236 ms
60,976 KB
testcase_31 AC 68 ms
25,556 KB
testcase_32 AC 101 ms
34,344 KB
testcase_33 AC 82 ms
27,736 KB
testcase_34 AC 105 ms
34,480 KB
testcase_35 AC 300 ms
67,040 KB
testcase_36 AC 102 ms
33,408 KB
権限があれば一括ダウンロードができます

ソースコード

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 c = NList;
        var (n, k) = (c[0], c[1]);
        var rest = n * (n + 1) / 2 - k;
        var set = new HashSet<long>();
        set.Add(0);
        for (var i = 1L; i <= n; ++i)
        {
            var d = i * (i + 1) / 2;
            if (set.Contains(d - rest))
            {
                WriteLine(1);
                return;
            }
            set.Add(d);
        }
        WriteLine(2);
    }
}
0