結果

問題 No.602 隠されていたゲーム2
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-11-28 23:37:35
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,292 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 15,048 KB
最終ジャッジ日時 2024-05-09 11:27:14
合計ジャッジ時間 6,485 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,400 KB
testcase_01 AC 13 ms
6,400 KB
testcase_02 AC 13 ms
6,272 KB
testcase_03 AC 12 ms
6,272 KB
testcase_04 AC 12 ms
6,400 KB
testcase_05 AC 11 ms
6,400 KB
testcase_06 AC 11 ms
6,400 KB
testcase_07 AC 11 ms
6,400 KB
testcase_08 AC 12 ms
6,400 KB
testcase_09 AC 12 ms
6,400 KB
testcase_10 AC 12 ms
6,400 KB
testcase_11 AC 11 ms
6,400 KB
testcase_12 AC 12 ms
6,400 KB
testcase_13 AC 12 ms
6,272 KB
testcase_14 AC 12 ms
6,272 KB
testcase_15 AC 11 ms
6,400 KB
testcase_16 AC 153 ms
7,296 KB
testcase_17 AC 363 ms
9,016 KB
testcase_18 AC 1,141 ms
13,176 KB
testcase_19 AC 1,292 ms
15,048 KB
testcase_20 AC 1,222 ms
14,924 KB
testcase_21 AC 955 ms
15,048 KB
testcase_22 AC 72 ms
15,048 KB
testcase_23 AC 89 ms
14,924 KB
権限があれば一括ダウンロードができます

ソースコード

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]
	for t in xrange(2):
		d1,d2 = d2,d1
		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(a>d1[mid] or 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