結果
問題 | No.545 ママの大事な二人の子供 |
ユーザー | hedwig100 |
提出日時 | 2020-05-29 11:49:21 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 754 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 155,404 KB |
最終ジャッジ日時 | 2024-04-22 16:23:17 |
合計ジャッジ時間 | 5,949 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
16,256 KB |
testcase_01 | AC | 33 ms
10,880 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 31 ms
10,880 KB |
testcase_05 | AC | 31 ms
10,880 KB |
testcase_06 | AC | 31 ms
10,880 KB |
testcase_07 | AC | 31 ms
10,880 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 31 ms
10,880 KB |
testcase_12 | WA | - |
testcase_13 | AC | 34 ms
11,008 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | TLE | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
ソースコード
from bisect import bisect_left,bisect_right N = int(input()) satisf = [tuple(map(int,input().split())) for _ in range(N)] if N == 1: print(min(satisf[0])) exit() left = [satisf[0][0],-satisf[0][1]] for x,y in satisf[1:int(N//2)]: left += [l + x for l in left] + [l - y for l in left] right = [satisf[N//2][0],-satisf[N//2][1]] for x,y in satisf[int(N//2) + 1:]: right += [r + x for r in right] + [r - y for r in right] right = list(set(right)) right.sort() ans = 1<<30 for l in left: idx = bisect_left(right,-l) if idx == len(right): ans = min(ans,abs(right[idx - 1] + l)) elif idx == 0: ans = min(ans,abs(right[0] + l)) else: ans = min(ans,abs(right[idx - 1] + l),abs(right[idx] + l)) print(ans)