結果
| 問題 | No.602 隠されていたゲーム2 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-12-02 01:24:39 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,381 bytes | 
| コンパイル時間 | 773 ms | 
| コンパイル使用メモリ | 105,600 KB | 
| 実行使用メモリ | 33,408 KB | 
| 最終ジャッジ日時 | 2024-11-28 02:05:45 | 
| 合計ジャッジ時間 | 2,638 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 WA * 9 | 
コンパイルメッセージ
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;
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 long[N];
        for (int i = 0; i < N; ++i) {
            D[i] = long.Parse(t[i]);
        }
        Array.Sort(D);
        s = Console.ReadLine();
        t = s.Split(' ');
        long x = long.Parse(t[0]);
        long y = long.Parse(t[1]);
        long X = Math.Abs(x + y);
        long Y = Math.Abs(x - y);
        long M = Math.Max(X, Y);
        if (x == 0 && y == 0) {
            Console.WriteLine(-1);
            return;
        }
        if (D.Contains(M)) {
            Console.WriteLine(1);
            return;
        } 
        for (int i = 0; i < N; ++i) {        
            int hi = N;
            int lo = 0;
            while (hi - lo > 1) {
                int mid = (hi + lo) / 2;
                if (D[mid] <= M + D[i]) {
                    lo = mid;
                } else {
                    hi = mid;
                }
            }
            if (lo == i) {
                lo -= 1;
            }
            if (lo >= 0 && lo < N && D[lo] <= M + D[i] && D[lo] >= M - D[i]) {
                Console.WriteLine(2);
                return;
            }
        }
        Console.WriteLine(-1);
    }
}
            
            
            
        