結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー Coki628Coki628
提出日時 2020-12-04 01:32:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,368 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 87,616 KB
実行使用メモリ 114,016 KB
最終ジャッジ日時 2023-10-12 12:49:39
合計ジャッジ時間 20,821 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,160 KB
testcase_01 AC 71 ms
71,424 KB
testcase_02 AC 71 ms
71,396 KB
testcase_03 AC 69 ms
71,464 KB
testcase_04 AC 70 ms
71,492 KB
testcase_05 AC 71 ms
71,400 KB
testcase_06 AC 71 ms
71,424 KB
testcase_07 AC 71 ms
71,436 KB
testcase_08 AC 77 ms
75,408 KB
testcase_09 AC 71 ms
71,372 KB
testcase_10 AC 72 ms
71,520 KB
testcase_11 AC 70 ms
71,376 KB
testcase_12 AC 70 ms
71,480 KB
testcase_13 AC 69 ms
71,408 KB
testcase_14 AC 73 ms
75,352 KB
testcase_15 AC 74 ms
75,388 KB
testcase_16 AC 75 ms
75,520 KB
testcase_17 AC 74 ms
75,752 KB
testcase_18 AC 344 ms
112,732 KB
testcase_19 AC 308 ms
109,264 KB
testcase_20 AC 209 ms
101,332 KB
testcase_21 AC 90 ms
76,436 KB
testcase_22 AC 211 ms
100,164 KB
testcase_23 AC 85 ms
76,084 KB
testcase_24 AC 256 ms
104,388 KB
testcase_25 AC 211 ms
100,660 KB
testcase_26 AC 121 ms
84,720 KB
testcase_27 AC 85 ms
76,336 KB
testcase_28 WA -
testcase_29 AC 333 ms
113,372 KB
testcase_30 AC 332 ms
113,088 KB
testcase_31 AC 325 ms
113,212 KB
testcase_32 AC 333 ms
113,364 KB
testcase_33 AC 328 ms
113,584 KB
testcase_34 AC 327 ms
113,892 KB
testcase_35 AC 333 ms
113,360 KB
testcase_36 AC 326 ms
113,760 KB
testcase_37 AC 329 ms
113,572 KB
testcase_38 AC 326 ms
113,912 KB
testcase_39 AC 326 ms
113,552 KB
testcase_40 AC 327 ms
113,368 KB
testcase_41 AC 327 ms
112,884 KB
testcase_42 AC 332 ms
113,428 KB
testcase_43 AC 70 ms
71,572 KB
testcase_44 AC 71 ms
71,532 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, ln=0):
    """ 三分探索 """

    m1 = lo
    m2 = hi
    while lo+2 < hi:
        m1 = (lo*2+hi) // 3
        m2 = (lo+hi*2) // 3
        res1 = func(m1)
        res2 = func(m2)
        if res1 <= res2:
            hi = m2
        else:
            lo = m1
    l, r = m1, m2
    mn = INF
    ret = ()
    for i in range(max(l-ln, lo), min(r+ln, hi)):
        res = func(i)
        if res < mn:
            mn = res
            ret = (i, res)
    return ret

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

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

A2 = sorted(A)
res = trisearch_min(0, N, check, 20)
print(A2[res[0]], res[1])
0