結果

問題 No.602 隠されていたゲーム2
ユーザー mkawa2mkawa2
提出日時 2021-11-27 15:05:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 1,401 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 96,276 KB
最終ジャッジ日時 2023-09-12 17:54:30
合計ジャッジ時間 4,001 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,228 KB
testcase_01 AC 73 ms
70,940 KB
testcase_02 AC 75 ms
71,320 KB
testcase_03 AC 77 ms
71,320 KB
testcase_04 AC 76 ms
71,264 KB
testcase_05 AC 74 ms
70,932 KB
testcase_06 AC 73 ms
71,300 KB
testcase_07 AC 73 ms
71,000 KB
testcase_08 AC 73 ms
70,896 KB
testcase_09 AC 73 ms
70,892 KB
testcase_10 AC 73 ms
71,216 KB
testcase_11 AC 73 ms
71,044 KB
testcase_12 AC 73 ms
71,440 KB
testcase_13 AC 73 ms
71,004 KB
testcase_14 AC 72 ms
71,296 KB
testcase_15 AC 72 ms
71,236 KB
testcase_16 AC 106 ms
77,756 KB
testcase_17 AC 96 ms
78,956 KB
testcase_18 AC 108 ms
90,732 KB
testcase_19 AC 123 ms
96,248 KB
testcase_20 AC 123 ms
95,556 KB
testcase_21 AC 111 ms
95,016 KB
testcase_22 AC 118 ms
95,540 KB
testcase_23 AC 100 ms
96,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = 18446744073709551615
inf = 4294967295
md = 10**9+7
# md = 998244353

from bisect import *

def solve():
    n = II()
    dd = LI()
    dd.sort()
    x, y = LI()
    x, y = abs(x+y), abs(x-y)
    if x < y: x, y = y, x

    if x == 0:
        print(0)
        return

    if x in dd:
        print(1)
        return

    dd0, dd1 = [], []
    for d in dd:
        if d & 1: dd1.append(d)
        else: dd0.append(d)

    mx0 = mx1 = -1
    if dd0: mx0 = max(dd0)
    if dd1: mx1 = max(dd1)

    if x%2 == 0:
        if x <= mx1*2 or x <= mx0*2:
            print(2)
        else:
            print(-1)
        return

    if dd0 and dd1:
        for d0 in dd0:
            i = bisect_left(dd1, abs(x-d0))
            if i < len(dd1) and dd1[i] <= x+d0:
                print(2)
                return

    print(-1)

solve()
0