結果

問題 No.1919 Many Monster Battles
ユーザー ShirotsumeShirotsume
提出日時 2022-04-05 01:06:13
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 824 ms / 2,000 ms
コード長 893 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 148,176 KB
最終ジャッジ日時 2023-09-02 13:48:58
合計ジャッジ時間 19,703 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,244 KB
testcase_01 AC 74 ms
71,104 KB
testcase_02 AC 72 ms
71,356 KB
testcase_03 AC 88 ms
76,592 KB
testcase_04 AC 89 ms
76,672 KB
testcase_05 AC 92 ms
76,668 KB
testcase_06 AC 87 ms
76,672 KB
testcase_07 AC 86 ms
76,408 KB
testcase_08 AC 88 ms
76,588 KB
testcase_09 AC 87 ms
76,464 KB
testcase_10 AC 87 ms
76,576 KB
testcase_11 AC 88 ms
76,580 KB
testcase_12 AC 89 ms
76,720 KB
testcase_13 AC 817 ms
148,176 KB
testcase_14 AC 815 ms
145,444 KB
testcase_15 AC 812 ms
146,732 KB
testcase_16 AC 820 ms
146,876 KB
testcase_17 AC 818 ms
145,948 KB
testcase_18 AC 654 ms
123,348 KB
testcase_19 AC 654 ms
123,712 KB
testcase_20 AC 656 ms
124,484 KB
testcase_21 AC 671 ms
123,028 KB
testcase_22 AC 656 ms
123,904 KB
testcase_23 AC 813 ms
146,448 KB
testcase_24 AC 816 ms
145,912 KB
testcase_25 AC 820 ms
146,976 KB
testcase_26 AC 823 ms
146,116 KB
testcase_27 AC 678 ms
145,740 KB
testcase_28 AC 673 ms
145,740 KB
testcase_29 AC 672 ms
146,992 KB
testcase_30 AC 677 ms
147,236 KB
testcase_31 AC 820 ms
146,736 KB
testcase_32 AC 824 ms
145,456 KB
testcase_33 AC 583 ms
122,804 KB
testcase_34 AC 586 ms
123,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7

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 ** 9 + 1

pow2 = pow(2, mod - 2, mod)
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)) * pow2


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
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