結果

問題 No.1919 Many Monster Battles
ユーザー とりゐとりゐ
提出日時 2023-03-11 17:16:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 451 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 81,944 KB
実行使用メモリ 175,584 KB
最終ジャッジ日時 2024-09-18 06:36:32
合計ジャッジ時間 12,878 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

def f(x):
  y=sorted(x)
  res=0
  for i in range(n):
    res+=y[i]%mod*(2*i-n+1)
    res%=mod
  return res

def g(x,y):
  u,v=[0]*n,[0]*n
  for i in range(n):
    u[i]=x[i]-y[i]
    v[i]=x[i]+y[i]
  return (f(u)+f(v))%mod

def calc(x,y):
  m=2*10**9
  return ((m+1)*g(x,y)-g([m*i for i in x],[(m+1)*i for i in y]))%mod

print(calc(a,b),calc(b,a))
0