結果
| 問題 |
No.243 出席番号(2)
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-10-16 17:50:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 922 bytes |
| コンパイル時間 | 1,965 ms |
| コンパイル使用メモリ | 194,984 KB |
| 実行使用メモリ | 199,464 KB |
| 最終ジャッジ日時 | 2025-10-16 17:50:55 |
| 合計ジャッジ時間 | 4,751 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 MLE * 20 |
ソースコード
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e3+10;
const int mod=1e9+7;
int n,a[N],t[N],dp[N][N];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
a[i]++;
t[a[i]]++;
}
dp[0][0]=1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=n;j++)
{
dp[i][j]=dp[i-1][j];
if(j!=0&&t[i]!=0)
{
dp[i][j]+=dp[i-1][j-1]*t[i];
dp[i][j]%=mod;
}
}
}
for(int i=0;i<=n;i++)
{
int us=n-i;
for(int j=1;j<=us;j++)
{
dp[n][i]*=j;
dp[n][i]%=mod;
}
}
int ans=0,f=1;
for(int i=0;i<=n;i++)
{
ans+=dp[n][i]*f;
f*=-1;
ans%=mod;
}
ans+=mod;
ans%=mod;
cout<<ans<<'\n';
return 0;
}
vjudge1