結果
問題 | No.602 隠されていたゲーム2 |
ユーザー |
![]() |
提出日時 | 2025-06-12 13:15:51 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 851 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 98,092 KB |
最終ジャッジ日時 | 2025-06-12 13:18:18 |
合計ジャッジ時間 | 2,587 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 6 |
ソースコード
import bisect def main(): import sys input = sys.stdin.read().split() idx = 0 n = int(input[idx]) idx += 1 d = list(map(int, input[idx:idx + n])) idx += n x = int(input[idx]) y = int(input[idx + 1]) idx += 2 if x == 0 and y == 0: print(0) return M = abs(x) + abs(y) d_sorted = sorted(d) # Check 1 move pos = bisect.bisect_left(d_sorted, M) if pos < len(d_sorted) and d_sorted[pos] == M: print(1) return # Check 2 moves for d1 in d_sorted: low = max(M - d1, d1 - M) low = max(low, 1) # since d_i >= 1 high = d1 + M left = bisect.bisect_left(d_sorted, low) if left < len(d_sorted) and d_sorted[left] <= high: print(2) return print(-1) if __name__ == "__main__": main()