結果

問題 No.602 隠されていたゲーム2
ユーザー vwxyzvwxyz
提出日時 2022-05-16 18:40:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 927 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 11,072 KB
実行使用メモリ 19,656 KB
最終ジャッジ日時 2023-10-12 12:26:31
合計ジャッジ時間 10,029 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,008 KB
testcase_01 AC 17 ms
8,052 KB
testcase_02 AC 16 ms
8,020 KB
testcase_03 AC 17 ms
8,052 KB
testcase_04 AC 17 ms
8,100 KB
testcase_05 AC 16 ms
8,080 KB
testcase_06 AC 16 ms
8,096 KB
testcase_07 WA -
testcase_08 AC 17 ms
8,096 KB
testcase_09 AC 17 ms
8,164 KB
testcase_10 AC 16 ms
8,144 KB
testcase_11 AC 16 ms
8,016 KB
testcase_12 AC 16 ms
8,100 KB
testcase_13 AC 16 ms
8,160 KB
testcase_14 AC 17 ms
8,172 KB
testcase_15 AC 16 ms
8,032 KB
testcase_16 AC 185 ms
9,924 KB
testcase_17 AC 401 ms
11,636 KB
testcase_18 AC 1,193 ms
17,036 KB
testcase_19 AC 1,323 ms
19,252 KB
testcase_20 AC 1,284 ms
19,284 KB
testcase_21 AC 1,396 ms
19,656 KB
testcase_22 AC 1,371 ms
19,268 KB
testcase_23 AC 1,151 ms
19,156 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 max(abs(x),abs(y)) in D:
    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