結果

問題 No.602 隠されていたゲーム2
ユーザー daku9640
提出日時 2017-12-03 00:53:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 799 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,916 KB
最終ジャッジ日時 2024-11-28 04:06:40
合計ジャッジ時間 2,442 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from heapq import heapify, heappush, heappop
readline = sys.stdin.readline
n = int(readline())
pq = [[], []]
d = tuple(map(int, readline().split()))
x, y = map(int, readline().split())
z = abs(x) + abs(y)
def solve():
    if z == 0: return 0
    if z in d: return 1
    for i in d:
        heappush(pq[i % 2], i)
    if z % 2 == 0:
        if pq[0]:
            if pq[0][0] * 2 >= z:
                return 2
        if pq[1]:
            if pq[1][0] * 2 >= z:
                return 2
    else:
        while pq[0] and pq[1]:
            t1 = pq[0][0]
            t2 = pq[1][0]
            if t1 + t2 >= z and abs(t1 - t2) <= z:
                return 2
            if t1 > t2:
                heappop(pq[0])
            else:
                heappop(pq[1])
    return -1
print(solve())
0