結果
| 問題 | No.602 隠されていたゲーム2 | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 18:27:40 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 525 bytes | 
| コンパイル時間 | 162 ms | 
| コンパイル使用メモリ | 82,716 KB | 
| 実行使用メモリ | 106,652 KB | 
| 最終ジャッジ日時 | 2025-06-12 18:27:43 | 
| 合計ジャッジ時間 | 2,350 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 16 WA * 5 | 
ソースコード
import bisect
n = int(input())
d = list(map(int, input().split()))
x, y = map(int, input().split())
D = abs(x) + abs(y)
d_set = set(d)
if D in d_set:
    print(1)
else:
    d_sorted = sorted(d)
    found = False
    for d1 in d_sorted:
        lower = max(D - d1, d1 - D)
        upper = d1 + D
        left = bisect.bisect_left(d_sorted, lower)
        right = bisect.bisect_right(d_sorted, upper)
        count = right - left
        if count >= 2:
            found = True
            break
    print(2 if found else -1)
            
            
            
        