結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-02 08:40:24 |
| 言語 | Python2 (2.7.18) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 705 bytes |
| コンパイル時間 | 414 ms |
| コンパイル使用メモリ | 6,912 KB |
| 実行使用メモリ | 21,404 KB |
| 最終ジャッジ日時 | 2024-11-28 03:31:13 |
| 合計ジャッジ時間 | 13,708 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 10 TLE * 4 |
ソースコード
#!/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