結果

問題 No.243 出席番号(2)
ユーザー tempura_pptempura_pp
提出日時 2018-10-14 18:29:49
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,010 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 87,744 KB
実行使用メモリ 234,620 KB
最終ジャッジ日時 2024-04-20 20:18:22
合計ジャッジ時間 3,624 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 17 ms
50,776 KB
testcase_04 AC 15 ms
51,016 KB
testcase_05 AC 14 ms
50,752 KB
testcase_06 AC 15 ms
50,788 KB
testcase_07 AC 15 ms
49,168 KB
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
testcase_27 MLE -
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[6000][6000];
ll cnt[6000];
int main(){
    int n;cin>>n;
    rep(i,n){
        int x;cin>>x;
        ++cnt[x];
    }
    dp[0][0]=1;
    rep(i,n)rep(j,n){
        dp[i][j]%=mod;
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j+1]+=dp[i][j]*cnt[i]%mod;
    }
    ll fact[6000];
    fact[0]=1;
    rep(i,n)fact[i+1]=fact[i]*(i+1)%mod;
    ll ans=0;
    rep(j,n+1){
        if(j%2==0)ans+=dp[n][j]*fact[n-j];
        else ans+=mod-dp[n][j]*fact[n-j]%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}
0