結果
| 問題 | No.1251 絶対に間違ってはいけない最小化問題 |
| コンテスト | |
| ユーザー |
uni_python
|
| 提出日時 | 2020-10-09 22:30:47 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 799 bytes |
| 記録 | |
| コンパイル時間 | 298 ms |
| コンパイル使用メモリ | 85,572 KB |
| 実行使用メモリ | 180,992 KB |
| 最終ジャッジ日時 | 2026-04-02 23:47:34 |
| 合計ジャッジ時間 | 41,320 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 40 |
ソースコード
import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
import bisect
N=I()
A=LI()
B=LI()
def calc(c):
temp=0
x=A[c]
for i in range(N):
temp+=B[i]*abs(x-A[i])
return temp
M=10**6+5
left=0
right=N-1
for i in range(500):
c1=(2*left+right)/3
c2=(left+2*right)/3
c1=int(c1)
c2=int(c2)
if calc(c1)<calc(c2):
right=c2
else:
left=c1
ll=calc(left)
rr=calc(right)
if ll<rr:
print(A[left],ll)
else:
print(A[right],rr)
main()
uni_python