結果

問題 No.1919 Many Monster Battles
ユーザー ShirotsumeShirotsume
提出日時 2022-04-05 01:00:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,016 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 240,332 KB
最終ジャッジ日時 2023-09-02 13:46:14
合計ジャッジ時間 6,209 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
78,332 KB
testcase_01 AC 71 ms
71,524 KB
testcase_02 AC 72 ms
71,392 KB
testcase_03 AC 102 ms
77,200 KB
testcase_04 AC 105 ms
77,608 KB
testcase_05 AC 104 ms
77,488 KB
testcase_06 AC 104 ms
77,524 KB
testcase_07 AC 104 ms
77,572 KB
testcase_08 AC 102 ms
77,592 KB
testcase_09 AC 103 ms
77,724 KB
testcase_10 AC 101 ms
77,544 KB
testcase_11 AC 106 ms
77,552 KB
testcase_12 AC 103 ms
77,480 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def sumofDiff(n, A):
    A.sort()
    s = 0
    ret = 0
    for i, v in enumerate(A):
        ret += i * v - s
        ret %= mod
        s += v
        s %= mod
    return ret
m = 10 ** 10
def sumofMax(n, a, b):
    x = [a[i] + b[i] for i in range(n)]
    y = [a[i] - b[i] for i in range(n)]
    return (sumofDiff(n, x) + sumofDiff(n, y)) * pow(2, mod - 2, mod)


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
mod = 10 ** 9 + 7
assert 1 <= n <= 2 * 10 ** 5
assert len(a) == len(b) == n
for v in a:
    assert 1 <= v <= 10 ** 9
for v in b:
    assert 1 <= v <= 10 ** 9

alice = 2 * (sumofMax(n, a, b) - sumofMax(n, [m * a[i] for i in range(n)], [(m + 1) * b[i] for i in range(n)]) + sumofMax(n, [m * a[i] for i in range(n)], [m * b[i] for i in range(n)]))

bob = 2 * (sumofMax(n, a, b) - sumofMax(n, [(m + 1) * a[i] for i in range(n)], [m * b[i] for i in range(n)]) + sumofMax(n, [m * a[i] for i in range(n)], [m * b[i] for i in range(n)]))

print((alice) % mod, (bob) % mod)
0