結果
問題 |
No.602 隠されていたゲーム2
|
ユーザー |
![]() |
提出日時 | 2025-06-12 19:42:15 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 850 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 82,340 KB |
実行使用メモリ | 84,244 KB |
最終ジャッジ日時 | 2025-06-12 19:42:18 |
合計ジャッジ時間 | 2,968 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 7 |
ソースコード
import bisect n = int(input()) d_list = list(map(int, input().split())) x, y = map(int, input().split()) m = abs(x) + abs(y) # Check if m can be achieved in one move if m in d_list: print(1) else: max_d = max(d_list) # Check if using the same distance twice can achieve m if 2 * max_d >= m: print(2) else: # Sort the list for binary search d_list_sorted = sorted(d_list) found = False for di in d_list_sorted: lower = max(m - di, di - m) upper = di + m # Find if any number in [lower, upper] exists in d_list_sorted left = bisect.bisect_left(d_list_sorted, lower) right = bisect.bisect_right(d_list_sorted, upper) if left < right: found = True break print(2 if found else -1)