結果

問題 No.118 門松列(2)
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-07-02 18:15:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 347 bytes
コンパイル時間 1,293 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 90,720 KB
最終ジャッジ日時 2023-09-23 14:24:51
合計ジャッジ時間 5,146 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
77,568 KB
testcase_01 AC 114 ms
90,720 KB
testcase_02 AC 113 ms
90,440 KB
testcase_03 AC 117 ms
90,684 KB
testcase_04 AC 117 ms
90,440 KB
testcase_05 AC 119 ms
90,708 KB
testcase_06 AC 98 ms
72,948 KB
testcase_07 AC 97 ms
72,952 KB
testcase_08 AC 94 ms
72,812 KB
testcase_09 AC 115 ms
89,004 KB
testcase_10 AC 102 ms
78,360 KB
testcase_11 AC 103 ms
79,616 KB
testcase_12 AC 101 ms
77,516 KB
testcase_13 AC 101 ms
77,868 KB
testcase_14 AC 119 ms
88,692 KB
testcase_15 AC 102 ms
77,916 KB
testcase_16 AC 115 ms
82,976 KB
testcase_17 AC 102 ms
77,788 KB
testcase_18 AC 105 ms
79,252 KB
testcase_19 AC 103 ms
81,940 KB
testcase_20 AC 107 ms
82,416 KB
testcase_21 AC 108 ms
87,372 KB
testcase_22 AC 100 ms
78,676 KB
testcase_23 AC 109 ms
86,184 KB
testcase_24 AC 102 ms
79,812 KB
testcase_25 AC 99 ms
81,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
# input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7

C = Counter(A)
ans = N*(N-1)*(N-2)//6

for v in C.values():
    
    ans -= v*(v-1)//2*(N-v) + v*(v-1)*(v-2)//6
    ans %= mod

print(ans)
0