結果
| 問題 | No.602 隠されていたゲーム2 |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-11-03 15:35:29 |
| 言語 | C# (.NET 10.0.403 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 2,412 bytes |
| 記録 | |
| コンパイル時間 | 14,763 ms |
| コンパイル使用メモリ | 174,180 KB |
| 実行使用メモリ | 48,768 KB |
| 最終ジャッジ日時 | 2026-11-03 15:35:48 |
| 合計ジャッジ時間 | 8,408 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 2 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (219 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.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();
public static void Main()
{
Solve();
}
static void Solve()
{
var n = NN;
var d = NList;
var c = NList;
var x = (long)Math.Abs(c[0]) + Math.Abs(c[1]);
var emax = -1;
var omax = -1;
var elist = new List<long>();
var olist = new List<long>();
if (x == 0)
{
WriteLine(0);
return;
}
foreach (var di in d)
{
if (x == di)
{
WriteLine(1);
return;
}
if (di % 2 == 0)
{
emax = Math.Max(emax, di * 2);
elist.Add(di);
}
else
{
omax = Math.Max(omax, di * 2);
olist.Add(di);
}
}
if (x % 2 == 0) WriteLine(x <= emax || x <= omax ? 2 : -1);
else
{
if (elist.Count == 0 || olist.Count == 0)
{
WriteLine(-1);
return;
}
elist.Sort();
olist.Sort();
foreach (var e in elist)
{
var opos = LowerBound(0, x - e, olist);
if (opos < olist.Count && Math.Abs(e - olist[opos]) <= x)
{
WriteLine(2);
return;
}
}
foreach (var o in olist)
{
var epos = LowerBound(0, x - o, elist);
if (epos < elist.Count && Math.Abs(o - elist[epos]) <= x)
{
WriteLine(2);
return;
}
}
WriteLine(-1);
}
}
static int LowerBound(int left, long min, IList<long> list)
{
if (list[left] >= min) return left;
var ng = left;
var ok = list.Count;
while (ok - ng > 1)
{
var mid = (ng + ok) / 2;
if (list[mid] < min) ng = mid;
else ok = mid;
}
return ok;
}
}