結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー 👑 kakel-sankakel-san
提出日時 2024-06-10 22:38:54
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 2,528 bytes
コンパイル時間 14,614 ms
コンパイル使用メモリ 169,596 KB
実行使用メモリ 191,456 KB
最終ジャッジ日時 2024-06-10 22:39:14
合計ジャッジ時間 17,080 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
30,336 KB
testcase_01 AC 56 ms
30,464 KB
testcase_02 AC 59 ms
30,456 KB
testcase_03 WA -
testcase_04 AC 56 ms
30,584 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 55 ms
30,592 KB
testcase_09 AC 54 ms
30,592 KB
testcase_10 AC 56 ms
30,464 KB
testcase_11 WA -
testcase_12 AC 57 ms
30,592 KB
testcase_13 AC 57 ms
30,640 KB
testcase_14 AC 55 ms
30,592 KB
testcase_15 WA -
testcase_16 AC 55 ms
30,720 KB
testcase_17 AC 61 ms
30,336 KB
testcase_18 AC 55 ms
30,564 KB
testcase_19 AC 54 ms
30,572 KB
testcase_20 AC 56 ms
30,208 KB
testcase_21 AC 56 ms
30,720 KB
testcase_22 AC 56 ms
30,456 KB
testcase_23 AC 56 ms
30,464 KB
testcase_24 AC 55 ms
30,336 KB
testcase_25 AC 55 ms
30,328 KB
testcase_26 AC 55 ms
30,456 KB
testcase_27 AC 56 ms
30,336 KB
testcase_28 AC 54 ms
30,720 KB
testcase_29 AC 57 ms
30,848 KB
testcase_30 AC 55 ms
30,336 KB
testcase_31 AC 55 ms
30,592 KB
testcase_32 AC 56 ms
30,336 KB
testcase_33 AC 55 ms
30,336 KB
testcase_34 AC 61 ms
30,564 KB
testcase_35 AC 54 ms
30,336 KB
testcase_36 AC 53 ms
30,820 KB
testcase_37 AC 74 ms
31,232 KB
testcase_38 AC 74 ms
31,360 KB
testcase_39 AC 74 ms
31,104 KB
testcase_40 AC 63 ms
31,104 KB
testcase_41 AC 64 ms
31,104 KB
testcase_42 AC 73 ms
31,104 KB
testcase_43 AC 61 ms
31,104 KB
testcase_44 AC 68 ms
30,976 KB
testcase_45 AC 72 ms
30,976 KB
testcase_46 WA -
testcase_47 AC 62 ms
32,256 KB
testcase_48 AC 65 ms
33,656 KB
testcase_49 AC 74 ms
31,104 KB
testcase_50 WA -
testcase_51 AC 81 ms
33,764 KB
testcase_52 AC 70 ms
33,792 KB
testcase_53 AC 69 ms
33,528 KB
testcase_54 AC 81 ms
33,920 KB
testcase_55 AC 70 ms
33,536 KB
testcase_56 AC 82 ms
191,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (89 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.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 int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k) = (c[0], c[1]);
        var a = NList;
        YN(Make(n, k, a));
    }
    static bool Make(int n, int k, int[] a)
    {
        var first = new HashSet<long>[4];
        for (var i = 0; i < first.Length; ++i) first[i] = new HashSet<long>();
        var bitmax = (int)Math.Pow(3, n / 2);
        for (var b = 0; b < bitmax; ++b)
        {
            var sum = 0L;
            var tmp = b;
            var plus = false;
            var minus = false;
            for (var i = 0; i < n / 2; ++i)
            {
                sum += a[i] * (tmp % 3 - 1);
                if (tmp % 3 == 0) minus = true;
                if (tmp % 3 == 2) plus = true;
                tmp /= 3;
            }
            if (!plus && !minus) first[0].Add(sum);
            else if (!plus && minus) first[1].Add(sum);
            else if (plus && !minus) first[2].Add(sum);
            else first[3].Add(sum);
        }
        bitmax = (int)Math.Pow(3, n - n / 2);
        for (var b = 0; b < bitmax; ++b)
        {
            var sum = 0L;
            var tmp = b;
            var plus = false;
            var minus = false;
            for (var i = 0; i < n - n / 2; ++i)
            {
                sum += a[i + n / 2] * (tmp % 3 - 1);
                if (tmp % 3 == 0) minus = true;
                if (tmp % 3 == 2) plus = true;
                tmp /= 3;
            }
            if (plus && minus)
            {
                if (first[0].Contains(k + sum) || first[0].Contains(sum - k)) return true;
            }
            if (plus)
            {
                if (first[1].Contains(k + sum) || first[1].Contains(sum - k)) return true;
            }
            if (minus)
            {
                if (first[2].Contains(k + sum) || first[2].Contains(sum - k)) return true;
            }
            if (first[3].Contains(k + sum) || first[3].Contains(sum - k)) return true;
        }
        return false;
    }
    static void YN(bool b)
    {
        WriteLine(b ? "Yes" : "No");
    }
}
0