結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー Coki628Coki628
提出日時 2020-12-03 23:32:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,204 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 87,520 KB
実行使用メモリ 111,448 KB
最終ジャッジ日時 2023-10-12 09:59:16
合計ジャッジ時間 23,034 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,872 KB
testcase_01 AC 75 ms
71,564 KB
testcase_02 AC 78 ms
76,252 KB
testcase_03 AC 79 ms
76,032 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 79 ms
76,196 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 78 ms
76,164 KB
testcase_11 WA -
testcase_12 AC 77 ms
76,068 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 79 ms
76,196 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 73 ms
71,780 KB
testcase_44 AC 79 ms
76,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

def trisearch_min(lo, hi, func, times):
    """ 三分探索(小数) """

    for _ in range(times):
        m1 = (lo*2+hi) / 3
        m2 = (lo+hi*2) / 3
        res1 = func(m1)
        res2 = func(m2)
        if res1 <= res2:
            hi = m2
        else:
            lo = m1
    return m1, m2

N = INT()
A = LIST()
B = LIST()

def check(m):
    res = 0
    for i in range(N):
        res += B[i] * abs(m-A[i])
    return res

res = trisearch_min(0, 10000000000, check, 100)
ans = round(check(res[0]))
print('{:.5f}'.format(res[0]), ans)
0