結果

問題 No.602 隠されていたゲーム2
ユーザー vwxyzvwxyz
提出日時 2022-05-16 18:41:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,410 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 19,608 KB
最終ジャッジ日時 2023-10-12 12:28:21
合計ジャッジ時間 10,251 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,020 KB
testcase_01 AC 16 ms
8,096 KB
testcase_02 AC 17 ms
8,016 KB
testcase_03 AC 16 ms
8,096 KB
testcase_04 AC 17 ms
8,140 KB
testcase_05 AC 16 ms
8,020 KB
testcase_06 AC 16 ms
8,020 KB
testcase_07 AC 17 ms
8,184 KB
testcase_08 AC 16 ms
8,212 KB
testcase_09 AC 17 ms
8,144 KB
testcase_10 AC 16 ms
8,088 KB
testcase_11 AC 17 ms
8,064 KB
testcase_12 AC 16 ms
8,064 KB
testcase_13 AC 16 ms
8,220 KB
testcase_14 AC 16 ms
8,064 KB
testcase_15 AC 16 ms
8,180 KB
testcase_16 AC 189 ms
9,848 KB
testcase_17 AC 397 ms
11,612 KB
testcase_18 AC 1,151 ms
17,032 KB
testcase_19 AC 1,340 ms
19,156 KB
testcase_20 AC 1,279 ms
19,264 KB
testcase_21 AC 1,410 ms
19,608 KB
testcase_22 AC 1,391 ms
19,200 KB
testcase_23 AC 1,130 ms
19,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left,bisect_right
import sys
readline=sys.stdin.readline

N=int(readline())
D=list(map(int,readline().split()))
D0=[d for d in D if d%2==0]
D1=[d for d in D if d%2==1]
D.sort()
D0.sort()
D1.sort()
x,y=map(int,readline().split())
x,y=x+y,x-y
ans=3
if (x,y)==(0,0):
    ans=min(ans,0)
if max(abs(x),abs(y)) in D:
    ans=min(ans,1)
for d in D:
    l,r=-d,d
    for a in (-d,d):
        for xx,yy in ((x,y),(y,x)):
            if l<=xx<=r:
                m=0 if xx%2==d%2 else 1
                M=max(abs(r-xx),abs(xx-l))
            else:
                m=min(abs(r-xx),abs(xx-l))
                M=max(abs(r-xx),abs(xx-l))
            m=max(m,abs(a-yy))
            M=max(M,abs(a-yy))
            if xx%2==d%2:
                if bisect_right(D0,M)-bisect_left(D0,m):
                    ans=min(ans,2)
            else:
                if bisect_right(D1,M)-bisect_left(D1,m):
                    ans=min(ans,2)
if ans==3:
    ans=-1
print(ans)
0