結果
問題 | No.243 出席番号(2) |
ユーザー |
|
提出日時 | 2021-06-23 23:11:17 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 770 ms / 2,000 ms |
コード長 | 677 bytes |
コンパイル時間 | 117 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 43,976 KB |
最終ジャッジ日時 | 2024-06-24 23:37:12 |
合計ジャッジ時間 | 21,709 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
import sysinput = lambda : sys.stdin.readline().rstrip()sys.setrecursionlimit(2*10**5+10)write = lambda x: sys.stdout.write(x+"\n")debug = lambda x: sys.stderr.write(x+"\n")writef = lambda x: print("{:.12f}".format(x))import numpy as npn = int(input())a = ([int(input()) for _ in range(n)])count = [0]*5000for v in (a):count[v] += 1M = 10**9+7ans = 0dp = np.zeros(n+1, dtype=np.int64)dp[0] = 1for k in range(n):v = count[k]if v==0:continuedp[1:] += dp[:-1]*v%Mg = [1]dp = dp.tolist()for i in range(1,n+1):g.append(g[-1]*i%M)s = 1for i in range(n+1):ans += s * dp[i] * g[n-i] % Mans %= Ms *= -1print(ans%M)