結果

問題 No.1919 Many Monster Battles
ユーザー とりゐとりゐ
提出日時 2022-04-10 03:37:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 517 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 244,160 KB
最終ジャッジ日時 2024-06-11 20:29:39
合計ジャッジ時間 13,610 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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,sm=0,0
  for i in range(n):
    res=(res+y[i]%mod*i-sm)%mod
    sm=(sm+y[i])%mod
  return res

def g(x,y):
  u,v=[],[]
  for i in range(n):
    u.append(x[i]-y[i])
    v.append(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