結果
| 問題 | 
                            No.1919 Many Monster Battles
                             | 
                    
| コンテスト | |
| ユーザー | 
                             とりゐ
                         | 
                    
| 提出日時 | 2022-04-04 00:01:28 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 565 bytes | 
| コンパイル時間 | 273 ms | 
| コンパイル使用メモリ | 82,180 KB | 
| 実行使用メモリ | 181,032 KB | 
| 最終ジャッジ日時 | 2024-06-11 20:23:52 | 
| 合計ジャッジ時間 | 14,001 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 6 WA * 26 | 
ソースコード
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
  sm=0
  for i in range(n):
    res+=i*y[i]-sm
    res%=mod
    sm+=y[i]
    sm%=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))//2
m=2*10**9
a1=[(m+1)*i for i in a]
a2=[m*i for i in a]
b1=[(m+1)*i for i in b]
b2=[m*i for i in b]
num1=g(a,b)
num2=g(a2,b1)
num3=g(a1,b2)
num4=g(a2,b2)
ans1=num1-num2+num4
ans2=num1-num3+num4
print(2*ans1%mod,2*ans2%mod)
            
            
            
        
            
とりゐ