結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
20,916 KB
testcase_01 AC 61 ms
20,788 KB
testcase_02 AC 62 ms
20,744 KB
testcase_03 AC 63 ms
18,788 KB
testcase_04 AC 64 ms
20,936 KB
testcase_05 AC 63 ms
18,764 KB
testcase_06 AC 63 ms
20,784 KB
testcase_07 WA -
testcase_08 AC 64 ms
20,852 KB
testcase_09 WA -
testcase_10 AC 64 ms
20,812 KB
testcase_11 AC 64 ms
20,764 KB
testcase_12 AC 63 ms
20,872 KB
testcase_13 AC 63 ms
20,780 KB
testcase_14 AC 64 ms
20,724 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 90 ms
22,736 KB
testcase_18 AC 122 ms
29,532 KB
testcase_19 AC 134 ms
30,308 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 147 ms
32,556 KB
testcase_23 AC 132 ms
30,320 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