結果
問題 |
No.243 出席番号(2)
|
ユーザー |
|
提出日時 | 2021-06-23 23:07:27 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 917 bytes |
コンパイル時間 | 257 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 44,148 KB |
最終ジャッジ日時 | 2024-06-24 23:32:23 |
合計ジャッジ時間 | 20,151 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 RE * 4 |
ソースコード
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)) import numpy as np n = int(input()) a = ([int(input()) for _ in range(n)]) count = [0]*n for v in (a): count[v] += 1 M = 10**9+7 ans = 0 dp = np.zeros(n+1, dtype=np.int64) dp[0] = 1 for k in range(n): v = count[k] if v==0: continue ndp = np.array(dp) ndp[1:] += dp[:-1]*v%M dp = ndp # 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] dp = dp.tolist() 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)