結果
| 問題 | No.118 門松列(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-23 20:56:34 |
| 言語 | PyPy2 (7.3.20) |
| 結果 |
AC
|
| 実行時間 | 130 ms / 5,000 ms |
| + 149µs | |
| コード長 | 414 bytes |
| 記録 | |
| コンパイル時間 | 67 ms |
| コンパイル使用メモリ | 80,592 KB |
| 実行使用メモリ | 102,508 KB |
| 最終ジャッジ日時 | 2026-07-17 13:19:56 |
| 合計ジャッジ時間 | 5,263 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#!/usr/bin/python
from fractions import Fraction
from collections import Counter
mul = lambda x, y: x*y
nCr = lambda n, r: int(reduce(mul, (Fraction(n-i, i+1) for i in xrange(r)), 1))
mod = int(1e9) + 7
n = int(raw_input())
As = map(int, raw_input().split())
res = nCr(n, 3)
for v in filter(lambda e: e>1, Counter(As).values()):
res -= nCr(v, 2) * (n-v)
if v >= 3:
res -= nCr(v, 3)
print res % mod