結果
| 問題 | No.602 隠されていたゲーム2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-03 00:25:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 800 ms / 2,000 ms |
| コード長 | 1,150 bytes |
| 記録 | |
| コンパイル時間 | 88 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 21,616 KB |
| 最終ジャッジ日時 | 2024-12-16 00:03:21 |
| 合計ジャッジ時間 | 4,750 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import sys
from itertools import combinations
readline = sys.stdin.readline
n = int(readline())
d = sorted(map(int, readline().split()))
x, y = map(int, readline().split())
l = abs(x) + abs(y)
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:
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 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)