結果

問題 No.602 隠されていたゲーム2
ユーザー daku9640daku9640
提出日時 2017-12-03 00:21:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 750 ms / 2,000 ms
コード長 981 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 11,008 KB
実行使用メモリ 19,684 KB
最終ジャッジ日時 2023-08-22 05:37:47
合計ジャッジ時間 4,887 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,196 KB
testcase_01 AC 17 ms
8,212 KB
testcase_02 AC 17 ms
8,264 KB
testcase_03 AC 17 ms
8,196 KB
testcase_04 AC 16 ms
8,212 KB
testcase_05 AC 17 ms
8,228 KB
testcase_06 AC 17 ms
8,136 KB
testcase_07 AC 16 ms
8,280 KB
testcase_08 AC 17 ms
8,140 KB
testcase_09 AC 17 ms
8,212 KB
testcase_10 AC 18 ms
8,248 KB
testcase_11 AC 16 ms
8,276 KB
testcase_12 AC 17 ms
8,284 KB
testcase_13 AC 17 ms
8,268 KB
testcase_14 AC 16 ms
8,208 KB
testcase_15 AC 16 ms
8,224 KB
testcase_16 AC 99 ms
9,764 KB
testcase_17 AC 208 ms
11,516 KB
testcase_18 AC 634 ms
16,880 KB
testcase_19 AC 750 ms
19,224 KB
testcase_20 AC 682 ms
19,684 KB
testcase_21 AC 739 ms
19,656 KB
testcase_22 AC 76 ms
19,236 KB
testcase_23 AC 60 ms
19,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0