結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー keijakkeijak
提出日時 2020-10-09 23:30:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 923 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 49,048 KB
最終ジャッジ日時 2023-09-27 19:52:41
合計ジャッジ時間 20,340 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,152 KB
testcase_01 AC 15 ms
8,144 KB
testcase_02 AC 14 ms
8,276 KB
testcase_03 AC 14 ms
8,224 KB
testcase_04 AC 14 ms
8,224 KB
testcase_05 AC 13 ms
8,276 KB
testcase_06 AC 14 ms
8,284 KB
testcase_07 AC 13 ms
8,236 KB
testcase_08 AC 14 ms
8,240 KB
testcase_09 AC 15 ms
8,280 KB
testcase_10 AC 14 ms
8,208 KB
testcase_11 AC 15 ms
8,224 KB
testcase_12 AC 15 ms
8,008 KB
testcase_13 AC 14 ms
8,276 KB
testcase_14 AC 13 ms
7,904 KB
testcase_15 AC 14 ms
8,152 KB
testcase_16 AC 14 ms
8,304 KB
testcase_17 AC 15 ms
8,316 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 38 ms
11,292 KB
testcase_22 WA -
testcase_23 AC 29 ms
10,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 71 ms
16,424 KB
testcase_27 AC 29 ms
10,480 KB
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 14 ms
8,144 KB
testcase_44 AC 15 ms
8,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    A = inl()
    B = inl()

    P = []
    for i in range(n):
        P.append((A[i], B[i]))
    P.sort()

    if n == 1:
        return A[0], 0

    cum = [None] * (n + 1)
    cum[0] = 0
    for i in range(n):
        cum[i + 1] = cum[i] + P[i][1]

    mp = n
    for i in range(n):
        if cum[i + 1] > cum[n] - cum[i + 1]:
            mp = i
            break

    def f(x):
        res = 0
        for i in range(n):
            res += B[i] * abs(x - A[i])
        return res

    if mp == n:
        y = max(A)
        return y, int(f(y) + 0.5)

    return P[mp][0], int(f(P[mp][0]) + 0.5)


print(*solve())
0