結果
問題 | No.602 隠されていたゲーム2 |
ユーザー |
|
提出日時 | 2017-12-02 22:15:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,636 bytes |
コンパイル時間 | 819 ms |
コンパイル使用メモリ | 104,192 KB |
実行使用メモリ | 29,440 KB |
最終ジャッジ日時 | 2024-11-28 03:47:36 |
合計ジャッジ時間 | 2,620 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; public class Program { static void Main() { string s = Console.ReadLine(); int N = int.Parse(s); s = Console.ReadLine(); var t = s.Split(' '); var D = new List<long>[2]; D[0] = new List<long>(); D[1] = new List<long>(); for (int i = 0; i < N; ++i) { var d = long.Parse(t[i]); D[d%2].Add(d); } D[0].Sort(); D[1].Sort(); s = Console.ReadLine(); t = s.Split(' '); long x = long.Parse(t[0]); long y = long.Parse(t[1]); long M = Math.Abs(x) + Math.Abs(y); if (x == 0 && y == 0) { Console.WriteLine(-1); return; } if (D[0].Contains(M) || D[1].Contains(M)) { Console.WriteLine(1); return; } for (int m2 = 0; m2 < 2; ++m2) { for (int i = 0; i < D[m2].Count; ++i) { int j = m2 ^ (int)(M%2); int hi = D[j].Count; int lo = 0; while (hi - lo > 1) { int mid = (hi + lo) / 2; if (D[j][mid] - D[m2][i] <= M) { lo = mid; } else { hi = mid; } } if (j < D[j].Count && D[j][lo] - D[m2][i] <= M && M <= D[j][lo] + D[m2][i]) { Console.WriteLine(2); return; } } } Console.WriteLine(-1); } }