結果

問題 No.2806 Cornflake Man
ユーザー 👑 kakel-sankakel-san
提出日時 2024-07-14 19:07:15
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 9,252 ms
コンパイル使用メモリ 168,756 KB
実行使用メモリ 186,476 KB
最終ジャッジ日時 2024-07-17 20:28:19
合計ジャッジ時間 11,252 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
53,504 KB
testcase_01 AC 113 ms
60,636 KB
testcase_02 AC 64 ms
34,944 KB
testcase_03 AC 112 ms
60,316 KB
testcase_04 AC 62 ms
34,432 KB
testcase_05 AC 67 ms
37,248 KB
testcase_06 AC 82 ms
42,336 KB
testcase_07 AC 120 ms
62,328 KB
testcase_08 AC 73 ms
41,600 KB
testcase_09 AC 89 ms
47,840 KB
testcase_10 AC 80 ms
41,344 KB
testcase_11 AC 61 ms
32,640 KB
testcase_12 AC 87 ms
43,776 KB
testcase_13 AC 114 ms
54,080 KB
testcase_14 AC 69 ms
35,840 KB
testcase_15 AC 129 ms
68,956 KB
testcase_16 AC 56 ms
29,952 KB
testcase_17 AC 50 ms
30,208 KB
testcase_18 AC 58 ms
30,464 KB
testcase_19 AC 52 ms
186,476 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (96 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();
    static int[] LList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => int.Parse(ReadLine())).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var a = NList;
        Array.Sort(a);
        var dic = new Dictionary<int, int>();
        foreach (var ai in a) dic[ai] = 0;
        var ans = new List<int>();
        foreach (var ai in a)
        {
            if (ai == 0) continue;
            if (dic[ai] > 0) continue;
            ans.Add(ai);
            for (var b = ai; b <= m; b += ai)
            {
                if (!dic.ContainsKey(b))
                {
                    WriteLine(-1);
                    return;
                }
                ++dic[b];
            }
        }
        WriteLine(ans.Count);
        WriteLine(string.Join(" ", ans));
    }
}
0