結果
問題 | No.602 隠されていたゲーム2 |
ユーザー |
|
提出日時 | 2017-12-03 00:21:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 799 ms / 2,000 ms |
コード長 | 981 bytes |
コンパイル時間 | 133 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 21,736 KB |
最終ジャッジ日時 | 2024-12-16 00:03:08 |
合計ジャッジ時間 | 4,976 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import sysfrom itertools import combinationsreadline = sys.stdin.readlinen = int(readline())d = sorted(map(int, readline().split()))x, y = map(int, readline().split())l = abs(x) + abs(y)ans = -1if l == 0:ans = 0elif l in d:ans = 1elif l%2==0:if max(d)*2 >= l:ans = 2else: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)-1while low < high:mid = (high+low) >> 1if(a+d1[mid]>=l): high = midelse: low = mid+1if(a+d1[low]<l): continueb = lowlow = 0; high = len(d1)-1while low < high:mid = (high+low+1) >> 1if(a>d1[mid] or abs(a-d1[mid])<=l): low = midelse: high = mid-1if(abs(a-d1[low])>l): continuec = lowif(b<=c):ans = 2print(ans)