結果

問題 No.243 出席番号(2)
ユーザー tempura_pptempura_pp
提出日時 2018-10-14 18:32:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 20:18:41
合計ジャッジ時間 1,855 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 8 ms
5,376 KB
testcase_12 AC 8 ms
5,376 KB
testcase_13 AC 16 ms
5,376 KB
testcase_14 AC 15 ms
5,376 KB
testcase_15 AC 16 ms
5,376 KB
testcase_16 AC 16 ms
5,376 KB
testcase_17 AC 15 ms
5,376 KB
testcase_18 AC 25 ms
5,376 KB
testcase_19 AC 25 ms
5,376 KB
testcase_20 AC 27 ms
5,376 KB
testcase_21 AC 26 ms
5,376 KB
testcase_22 AC 26 ms
5,376 KB
testcase_23 AC 40 ms
5,376 KB
testcase_24 AC 39 ms
5,376 KB
testcase_25 AC 39 ms
5,376 KB
testcase_26 AC 40 ms
5,376 KB
testcase_27 AC 39 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 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];
ll cnt[6000];
int main(){
    int n;cin>>n;
    rep(i,n){
        int x;cin>>x;
        ++cnt[x];
    }
    dp[0]=1;
    rep(i,n)for(int j=n;j>=0;--j){
        (dp[j+1]+=dp[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[j]*fact[n-j];
        else ans+=mod-dp[j]*fact[n-j]%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}
0