結果

問題 No.602 隠されていたゲーム2
ユーザー nebukuro09nebukuro09
提出日時 2017-12-02 22:32:14
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,635 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 103,424 KB
実行使用メモリ 33,244 KB
最終ジャッジ日時 2023-08-18 20:09:00
合計ジャッジ時間 5,213 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,760 KB
testcase_01 AC 57 ms
20,800 KB
testcase_02 AC 57 ms
20,724 KB
testcase_03 AC 59 ms
22,796 KB
testcase_04 AC 61 ms
20,916 KB
testcase_05 AC 62 ms
20,768 KB
testcase_06 AC 58 ms
22,852 KB
testcase_07 AC 57 ms
20,796 KB
testcase_08 AC 59 ms
20,776 KB
testcase_09 WA -
testcase_10 AC 59 ms
22,828 KB
testcase_11 AC 60 ms
22,804 KB
testcase_12 AC 61 ms
22,928 KB
testcase_13 AC 60 ms
22,860 KB
testcase_14 AC 61 ms
20,776 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 88 ms
22,664 KB
testcase_18 AC 116 ms
29,440 KB
testcase_19 AC 124 ms
30,516 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 133 ms
30,520 KB
testcase_23 AC 127 ms
30,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
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(0);
            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);
        
    }
}
0