結果
| 問題 |
No.2806 Cornflake Man
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-14 19:07:15 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /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/
ソースコード
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));
}
}