結果

問題 No.602 隠されていたゲーム2
ユーザー nebukuro09nebukuro09
提出日時 2017-12-02 01:15:22
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,263 bytes
コンパイル時間 3,102 ms
コンパイル使用メモリ 103,176 KB
実行使用メモリ 36,972 KB
最終ジャッジ日時 2023-08-18 18:49:31
合計ジャッジ時間 6,121 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
21,440 KB
testcase_01 AC 55 ms
21,760 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 56 ms
23,532 KB
testcase_05 AC 60 ms
21,628 KB
testcase_06 AC 59 ms
21,584 KB
testcase_07 RE -
testcase_08 AC 57 ms
21,448 KB
testcase_09 RE -
testcase_10 AC 55 ms
23,612 KB
testcase_11 AC 54 ms
23,692 KB
testcase_12 AC 55 ms
23,572 KB
testcase_13 AC 53 ms
19,640 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 111 ms
35,560 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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 int[N];
        for (int i = 0; i < N; ++i) {
            D[i] = int.Parse(t[i]);
        }
        Array.Sort(D);

        s = Console.ReadLine();
        t = s.Split(' ');

        int x = int.Parse(t[0]);
        int y = int.Parse(t[1]);

        int X = Math.Abs(x + y);
        int Y = Math.Abs(x - y);
        int M = Math.Max(X, Y);

        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 < N && D[lo] <= M + D[i] && D[lo] >= M - D[i]) {
                Console.WriteLine(2);
                return;
            }
        }

        Console.WriteLine(-1);
    }
}
0