結果
| 問題 |
No.118 門松列(2)
|
| ユーザー |
zombietan
|
| 提出日時 | 2016-05-22 16:42:18 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 5,000 ms |
| コード長 | 454 bytes |
| コンパイル時間 | 244 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 16,764 KB |
| 最終ジャッジ日時 | 2024-10-09 08:11:27 |
| 合計ジャッジ時間 | 2,588 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
ans = N*(N-1)*(N-2)//6
cnt = Counter(A)
def same3(n):
return n*(n-1)*(n-2)//6
def same2(n):
return n*(n-1)//2
def not_kadomatu(n, m):
if m == 2:
return same2(m)*n - m
else:
return same2(m)*(n-m) + same3(m)
for count in cnt.values():
if count >= 2:
nk = not_kadomatu(N,count)
ans = ans - nk
print(ans%1000000007)
zombietan