結果
問題 | No.602 隠されていたゲーム2 |
ユーザー | wajima_wataru |
提出日時 | 2017-12-03 19:11:06 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
AC
|
実行時間 | 631 ms / 2,000 ms |
コード長 | 1,375 bytes |
コンパイル時間 | 254 ms |
コンパイル使用メモリ | 10,932 KB |
実行使用メモリ | 19,248 KB |
最終ジャッジ日時 | 2023-08-22 05:40:06 |
合計ジャッジ時間 | 3,823 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,348 KB |
testcase_01 | AC | 16 ms
8,284 KB |
testcase_02 | AC | 17 ms
8,120 KB |
testcase_03 | AC | 17 ms
8,096 KB |
testcase_04 | AC | 17 ms
8,376 KB |
testcase_05 | AC | 17 ms
8,324 KB |
testcase_06 | AC | 17 ms
8,252 KB |
testcase_07 | AC | 17 ms
8,368 KB |
testcase_08 | AC | 17 ms
8,284 KB |
testcase_09 | AC | 16 ms
8,384 KB |
testcase_10 | AC | 17 ms
8,296 KB |
testcase_11 | AC | 17 ms
8,392 KB |
testcase_12 | AC | 17 ms
8,344 KB |
testcase_13 | AC | 17 ms
8,272 KB |
testcase_14 | AC | 16 ms
8,272 KB |
testcase_15 | AC | 17 ms
8,116 KB |
testcase_16 | AC | 91 ms
9,772 KB |
testcase_17 | AC | 47 ms
11,708 KB |
testcase_18 | AC | 84 ms
16,956 KB |
testcase_19 | AC | 99 ms
19,248 KB |
testcase_20 | AC | 631 ms
19,092 KB |
testcase_21 | AC | 588 ms
19,136 KB |
testcase_22 | AC | 387 ms
19,220 KB |
testcase_23 | AC | 147 ms
19,224 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)