結果

問題 No.602 隠されていたゲーム2
ユーザー nmnmnmnmnmnmnm
提出日時 2017-11-28 23:44:55
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 885 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 6,820 KB
実行使用メモリ 14,920 KB
最終ジャッジ日時 2024-11-27 13:23:03
合計ジャッジ時間 3,825 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input();
d = map(int,raw_input().split())
[x,y] = map(int,raw_input().split())
l = abs(x)+abs(y)

if(not(1<=n<=100000)): print("error")
for a in d:
	if(not(1<=a<=1000000000)): print("error")
if(not(-1000000000<=x<=1000000000)): print("error")
if(not(-1000000000<=y<=1000000000)): print("error")

ans = -1
if l == 0: ans = 0
elif l in d: ans = 1
elif l%2==0:
	if max(d)*2 >= l: ans = 2
else:
	d.sort()
	d1 = [x for x in d if x%2==0]
	d2 = [x for x in d if x%2==1]
	if d1 != []:
		for a in d2:
			low = 0; high = len(d1)-1
			while low < high:
				mid = (high+low) >> 1;
				if(a+d1[mid]>=l): high = mid
				else: low = mid+1
			if(a+d1[low]<l): continue
			b = low
			low = 0; high = len(d1)-1
			while low < high:
				mid = (high+low+1) >> 1;
				if(0<=abs(a-d1[mid])<=l): low = mid
				else: high = mid-1
			if(abs(a-d1[low])>l): continue
			c = low
			if(b<=c): ans = 2
print ans
0