結果

問題 No.602 隠されていたゲーム2
ユーザー mkawa2mkawa2
提出日時 2021-11-26 15:38:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,329 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 19,348 KB
最終ジャッジ日時 2023-09-11 22:43:59
合計ジャッジ時間 1,971 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,348 KB
testcase_01 AC 18 ms
8,156 KB
testcase_02 AC 18 ms
8,232 KB
testcase_03 AC 17 ms
8,436 KB
testcase_04 AC 16 ms
8,336 KB
testcase_05 AC 16 ms
8,280 KB
testcase_06 AC 16 ms
8,248 KB
testcase_07 AC 16 ms
8,284 KB
testcase_08 AC 16 ms
8,280 KB
testcase_09 AC 16 ms
8,252 KB
testcase_10 AC 17 ms
8,284 KB
testcase_11 AC 16 ms
8,264 KB
testcase_12 AC 17 ms
8,280 KB
testcase_13 AC 17 ms
8,408 KB
testcase_14 AC 16 ms
8,416 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 28 ms
11,592 KB
testcase_18 AC 47 ms
16,900 KB
testcase_19 AC 55 ms
19,068 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 55 ms
19,228 KB
testcase_23 AC 58 ms
19,296 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

def solve():
    n = II()
    dd = LI()
    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 = [0], [0]
    for d in dd:
        if d & 1: dd1.append(d)
        else: dd0.append(d)

    mx0 = max(dd0)
    mx1 = max(dd1)

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

    for d in dd0:
        if x-mx1 <= d <= x+mx1:
            print(2)
            return
    for d in dd1:
        if x-mx0 <= d <= x+mx0:
            print(2)
            return

    print(-1)

solve()
0