結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,520 KB
testcase_01 AC 74 ms
71,192 KB
testcase_02 AC 73 ms
71,260 KB
testcase_03 AC 110 ms
77,404 KB
testcase_04 AC 108 ms
77,360 KB
testcase_05 AC 104 ms
77,516 KB
testcase_06 AC 103 ms
77,136 KB
testcase_07 AC 104 ms
77,492 KB
testcase_08 AC 102 ms
77,208 KB
testcase_09 AC 106 ms
77,588 KB
testcase_10 AC 101 ms
77,356 KB
testcase_11 AC 105 ms
77,436 KB
testcase_12 AC 103 ms
77,336 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 726 ms
123,576 KB
testcase_19 AC 727 ms
123,888 KB
testcase_20 AC 721 ms
124,564 KB
testcase_21 AC 719 ms
123,236 KB
testcase_22 AC 718 ms
123,644 KB
testcase_23 AC 1,822 ms
188,344 KB
testcase_24 AC 1,815 ms
188,648 KB
testcase_25 AC 1,798 ms
179,568 KB
testcase_26 AC 1,826 ms
180,136 KB
testcase_27 AC 1,687 ms
157,388 KB
testcase_28 AC 1,467 ms
158,956 KB
testcase_29 AC 1,678 ms
173,312 KB
testcase_30 AC 1,450 ms
156,344 KB
testcase_31 TLE -
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
        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