結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
78,644 KB
testcase_01 AC 70 ms
71,548 KB
testcase_02 AC 71 ms
71,436 KB
testcase_03 AC 101 ms
77,472 KB
testcase_04 AC 103 ms
77,468 KB
testcase_05 AC 101 ms
77,424 KB
testcase_06 AC 103 ms
77,724 KB
testcase_07 AC 106 ms
77,608 KB
testcase_08 AC 104 ms
77,420 KB
testcase_09 AC 106 ms
77,708 KB
testcase_10 AC 105 ms
77,572 KB
testcase_11 AC 108 ms
77,628 KB
testcase_12 AC 105 ms
77,504 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
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