結果
問題 |
No.243 出席番号(2)
|
ユーザー |
|
提出日時 | 2021-06-23 22:58:53 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 764 bytes |
コンパイル時間 | 272 ms |
コンパイル使用メモリ | 82,236 KB |
実行使用メモリ | 77,856 KB |
最終ジャッジ日時 | 2024-06-24 23:22:16 |
合計ジャッジ時間 | 3,661 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 MLE * 24 |
ソースコード
import sys input = 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)) n = int(input()) a = [int(input()) for _ in range(n)] from collections import Counter count = Counter(a) M = 10**9+7 ans = 0 dp = [0]*(n+1) dp[0] = 1 for k,v in count.items(): ndp = [0]*(n+1) for b in range(n): val = dp[b] if val==0: continue ndp[b] += val ndp[b+1] += v*val%M ndp[b] %= M ndp[b+1] %= M dp = ndp g = [1] for i in range(1,n+1): g.append(g[-1]*i%M) s = 1 for i in range(n+1): ans += s * dp[i] * g[n-i] % M ans %= M s *= -1 print(ans%M)