結果
| 問題 | No.602 隠されていたゲーム2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-02 08:40:24 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 705 bytes |
| 記録 | |
| コンパイル時間 | 131 ms |
| コンパイル使用メモリ | 77,428 KB |
| 最終ジャッジ日時 | 2025-12-04 00:48:38 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 9 TLE * 1 -- * 5 |
ソースコード
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
from bisect import bisect_left
def index(arr, x):
i = bisect_left(arr, x)
return i if i!=len(arr) and arr[i]==x else -1
exists = lambda arr, x: index(arr, x) >= 0
n = int(raw_input())
d = map(int, raw_input().split())
d.sort()
def f(x, y):
if (x, y) == (0, 0):
return 0
dist = abs(x) + abs(y)
# 1回でいけるか
if exists(d, dist):
return 1
# 2回でいけるか
for i in xrange(n):
left = dist - d[i]
if left < 0:
break
if exists(d[:i], left) or exists(d[i+1:], left):
return 2
return -1
x, y = map(int, raw_input().split())
res = f(x, y)
print res