結果
問題 |
No.602 隠されていたゲーム2
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:44:09 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 758 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 109,748 KB |
最終ジャッジ日時 | 2025-03-31 17:45:09 |
合計ジャッジ時間 | 2,678 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 4 |
ソースコード
import sys import bisect n = int(sys.stdin.readline()) d_list = list(map(int, sys.stdin.readline().split())) x, y = map(int, sys.stdin.readline().split()) D = abs(x) + abs(y) if D == 0: print(0) sys.exit() d_set = set(d_list) if D in d_set: print(1) sys.exit() # Preprocess even and odd lists, sorted even = [] odd = [] for d in d_list: if d % 2 == 0: even.append(d) else: odd.append(d) even.sort() odd.sort() found = False for d1 in d_list: K = max(D - d1, 0) target_parity = (D + d1) % 2 target = even if target_parity == 0 else odd if not target: continue idx = bisect.bisect_left(target, K) if idx < len(target): found = True break print(2 if found else -1)