結果
問題 | No.1251 絶対に間違ってはいけない最小化問題 |
ユーザー |
![]() |
提出日時 | 2020-10-09 22:30:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 702 ms / 2,000 ms |
コード長 | 697 bytes |
コンパイル時間 | 166 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 148,820 KB |
最終ジャッジ日時 | 2024-07-20 12:50:58 |
合計ジャッジ時間 | 25,951 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
n = int(input())A = list(map(int, input().split()))B = list(map(int, input().split()))AB = []for a, b in zip(A, B):AB.append((a, b))AB.sort()B_ = []for _, b in AB:B_.append(b)mab = []for a, b in AB:mab.append(a*b)from itertools import accumulatecumb = [0]+B_cumb = list(accumulate(cumb))cumab = [0]+mabcumab = list(accumulate(cumab))m = 10**19ans = -10**18for i in range(n):x = AB[i][0]#temp1 = 0#for a, b in AB:#temp1 += b*abs(x-a)temp = 0temp = (cumb[i]-cumb[0]-cumb[n]+cumb[i])*xtemp += -cumab[i]+cumab[0]+(cumab[n]-cumab[i])#print(x, temp1, temp)if temp <= m:ans = xm = tempprint(ans, m)