結果

問題 No.1919 Many Monster Battles
ユーザー ShirotsumeShirotsume
提出日時 2022-04-05 00:58:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 996 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 139,188 KB
最終ジャッジ日時 2023-09-02 13:45:57
合計ジャッジ時間 18,454 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,520 KB
testcase_01 AC 72 ms
71,548 KB
testcase_02 AC 73 ms
71,320 KB
testcase_03 AC 84 ms
76,788 KB
testcase_04 AC 84 ms
76,688 KB
testcase_05 AC 85 ms
76,700 KB
testcase_06 AC 84 ms
76,552 KB
testcase_07 AC 85 ms
76,380 KB
testcase_08 AC 86 ms
76,740 KB
testcase_09 AC 84 ms
76,732 KB
testcase_10 AC 83 ms
76,576 KB
testcase_11 AC 85 ms
76,492 KB
testcase_12 AC 86 ms
76,740 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 633 ms
123,552 KB
testcase_19 AC 630 ms
123,948 KB
testcase_20 AC 624 ms
124,520 KB
testcase_21 AC 629 ms
123,144 KB
testcase_22 AC 627 ms
123,956 KB
testcase_23 AC 714 ms
137,948 KB
testcase_24 AC 700 ms
138,140 KB
testcase_25 AC 719 ms
137,280 KB
testcase_26 AC 718 ms
137,880 KB
testcase_27 AC 589 ms
137,372 KB
testcase_28 AC 568 ms
137,608 KB
testcase_29 AC 591 ms
139,188 KB
testcase_30 AC 560 ms
138,724 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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 ** 6
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