結果

問題 No.118 門松列(2)
ユーザー vwxyz
提出日時 2022-10-18 10:51:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 265 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 16,728 KB
最終ジャッジ日時 2024-06-28 19:52:54
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import Counter
readline=sys.stdin.readline

N=int(readline())
A=list(map(int,readline().split()))
C=Counter(A)
ans=N*(N-1)*(N-2)
for c in C.values():
    ans-=c*(c-1)*(c-2)
    ans-=c*(c-1)*(N-c)*3
ans//=6
mod=10**9+7
ans%=mod
print(ans)
0