結果

問題 No.118 門松列(2)
ユーザー 👑 KazunKazun
提出日時 2020-11-28 17:46:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 172 ms / 5,000 ms
コード長 331 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 90,288 KB
最終ジャッジ日時 2023-10-10 00:48:14
合計ジャッジ時間 5,176 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,896 KB
testcase_01 AC 172 ms
90,288 KB
testcase_02 AC 166 ms
90,260 KB
testcase_03 AC 170 ms
89,944 KB
testcase_04 AC 126 ms
89,992 KB
testcase_05 AC 131 ms
90,112 KB
testcase_06 AC 67 ms
71,376 KB
testcase_07 AC 67 ms
71,264 KB
testcase_08 AC 67 ms
71,336 KB
testcase_09 AC 162 ms
88,580 KB
testcase_10 AC 82 ms
77,172 KB
testcase_11 AC 88 ms
78,632 KB
testcase_12 AC 77 ms
76,820 KB
testcase_13 AC 77 ms
76,876 KB
testcase_14 AC 166 ms
88,444 KB
testcase_15 AC 79 ms
76,832 KB
testcase_16 AC 105 ms
82,200 KB
testcase_17 AC 79 ms
76,792 KB
testcase_18 AC 99 ms
78,728 KB
testcase_19 AC 97 ms
80,960 KB
testcase_20 AC 100 ms
81,680 KB
testcase_21 AC 149 ms
86,748 KB
testcase_22 AC 95 ms
77,768 KB
testcase_23 AC 113 ms
85,216 KB
testcase_24 AC 90 ms
79,056 KB
testcase_25 AC 100 ms
81,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
A.sort()

K=0;Mod=10**9+7;two_inv=pow(2,Mod-2,Mod)
A_max=max(A)

X=[0]*(A_max+1)
for a in A:
    X[a]+=1

for a in A:
    x1=x2=0
    for b in range(a):
        x1+=X[b]
        x2+=X[b]*X[b]
    K+=x1*x1-x2
    K%=Mod

K=(K*two_inv)%Mod
print(K)
0