結果

問題 No.118 門松列(2)
ユーザー maspy
提出日時 2020-01-29 19:03:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 478 ms / 5,000 ms
コード長 374 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 46,760 KB
最終ジャッジ日時 2024-09-16 01:56:21
合計ジャッジ時間 15,215 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = np.array(read().split(),np.int64)

cnt = np.bincount(A)

two = cnt * (cnt-1) // 2 * (N-cnt)
three = cnt * (cnt-1) * (cnt-2) // 6

x = N * (N-1) * (N-2) // 6
x -= (two + three).sum()

MOD = 10**9 + 7
print(x % MOD)
0