結果

問題 No.602 隠されていたゲーム2
ユーザー nebukuro09nebukuro09
提出日時 2017-12-02 22:15:14
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,636 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 104,576 KB
実行使用メモリ 29,440 KB
最終ジャッジ日時 2024-05-06 01:52:03
合計ジャッジ時間 2,788 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
17,920 KB
testcase_01 AC 22 ms
17,920 KB
testcase_02 AC 21 ms
17,664 KB
testcase_03 AC 21 ms
18,048 KB
testcase_04 AC 25 ms
18,176 KB
testcase_05 AC 24 ms
18,048 KB
testcase_06 AC 23 ms
18,048 KB
testcase_07 WA -
testcase_08 AC 22 ms
18,176 KB
testcase_09 WA -
testcase_10 AC 22 ms
18,048 KB
testcase_11 AC 22 ms
18,176 KB
testcase_12 AC 24 ms
17,920 KB
testcase_13 AC 24 ms
18,176 KB
testcase_14 AC 23 ms
18,048 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 45 ms
21,248 KB
testcase_18 AC 74 ms
27,648 KB
testcase_19 AC 87 ms
29,440 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 95 ms
29,440 KB
testcase_23 AC 86 ms
28,800 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(-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);
        
    }
}
0