結果
| 問題 | No.1251 絶対に間違ってはいけない最小化問題 | 
| コンテスト | |
| ユーザー |  tktk_snsn | 
| 提出日時 | 2021-04-23 20:13:35 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 356 bytes | 
| コンパイル時間 | 187 ms | 
| コンパイル使用メモリ | 12,416 KB | 
| 実行使用メモリ | 38,696 KB | 
| 最終ジャッジ日時 | 2024-07-04 07:17:22 | 
| 合計ジャッジ時間 | 29,817 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 2 WA * 40 | 
ソースコード
from functools import lru_cache
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
@lru_cache(maxsize=None)
def F(x):
    return sum(b * abs(x - a) for a, b in zip(A, B))
D = n.bit_length()
i = 0
C = sorted(A)
for d in reversed(range(D)):
    shift = 1 << d
    if F(i) > F(i+d):
        i += shift
print(i, F(i))
            
            
            
        