結果
問題 | No.602 隠されていたゲーム2 |
ユーザー | wajima_wataru |
提出日時 | 2017-12-03 19:11:06 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 783 ms / 2,000 ms |
コード長 | 1,375 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 21,808 KB |
最終ジャッジ日時 | 2024-05-09 11:36:00 |
合計ジャッジ時間 | 4,192 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,880 KB |
testcase_01 | AC | 30 ms
10,880 KB |
testcase_02 | AC | 30 ms
10,880 KB |
testcase_03 | AC | 30 ms
10,880 KB |
testcase_04 | AC | 30 ms
10,880 KB |
testcase_05 | AC | 31 ms
10,880 KB |
testcase_06 | AC | 29 ms
11,008 KB |
testcase_07 | AC | 30 ms
10,880 KB |
testcase_08 | AC | 29 ms
10,752 KB |
testcase_09 | AC | 31 ms
10,880 KB |
testcase_10 | AC | 30 ms
10,880 KB |
testcase_11 | AC | 33 ms
10,880 KB |
testcase_12 | AC | 29 ms
10,752 KB |
testcase_13 | AC | 30 ms
10,880 KB |
testcase_14 | AC | 30 ms
10,880 KB |
testcase_15 | AC | 30 ms
10,752 KB |
testcase_16 | AC | 121 ms
12,288 KB |
testcase_17 | AC | 64 ms
14,260 KB |
testcase_18 | AC | 97 ms
19,480 KB |
testcase_19 | AC | 114 ms
21,660 KB |
testcase_20 | AC | 783 ms
19,988 KB |
testcase_21 | AC | 761 ms
20,808 KB |
testcase_22 | AC | 509 ms
21,660 KB |
testcase_23 | AC | 169 ms
21,808 KB |
ソースコード
import sys readline = sys.stdin.readline n = int(input()) d_arr = list(map(int, readline().split())) d_even = [] d_odd = [] for d in d_arr: if d % 2 == 0: d_even.append(d) else: d_odd.append(d) d_even.sort() d_odd.sort() x, y = map(lambda n: abs(int(n)), input().split()) if x == 0 and y == 0: print(0) sys.exit() for d in d_arr: if d == x + y: print(1) sys.exit() def find(x, i): if len(x) == 0: return -1 low = 0 high = len(x) - 1 t = (low + high) // 2 while low <= high: if (i == x[t]): break elif (i > x[t]): low = t + 1 elif (i < x[t]): high = t - 1 t = (low + high) // 2 if (i == x[t]): print(2) sys.exit() else: return t + 1 for d in d_even: if (x + y) % 2 == 0: if find(d_even, abs(x + y - d)) < find(d_even, x + y + d): print(2) sys.exit() else: if find(d_odd, abs(x + y - d)) < find(d_odd, x + y + d): print(2) sys.exit() for d in d_odd: if (x + y) % 2 == 0: if find(d_odd, abs(x + y - d)) < find(d_odd, x + y + d): print(2) sys.exit() else: if find(d_even, abs(x + y - d)) < find(d_even, x + y + d): print(2) sys.exit() print(-1)