結果

問題 No.467 隠されていたゲーム
ユーザー lam6er
提出日時 2025-03-31 17:57:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 54,240 KB
最終ジャッジ日時 2025-03-31 17:58:32
合計ジャッジ時間 2,267 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
d = list(map(int, input().split()))
x, y = map(int, input().split())
D = max(abs(x), abs(y))

if D == 0:
    print(0)
    exit()

max_d = max(d)
all_even = all(di % 2 == 0 for di in d)
all_odd = all(di % 2 == 1 for di in d)
D_parity = D % 2

k_start = (D + max_d - 1) // max_d

if all_even:
    if D_parity != 0:
        print(-1)
    else:
        print(k_start)
elif all_odd:
    found_k = -1
    # Check k_start and k_start +1
    for k in [k_start, k_start + 1]:
        if k % 2 == D_parity and max_d * k >= D:
            found_k = k
            break
    print(found_k if found_k != -1 else -1)
else:
    print(k_start)
0