結果
問題 | No.243 出席番号(2) |
ユーザー | ぷら |
提出日時 | 2022-08-26 20:25:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 866 bytes |
コンパイル時間 | 2,439 ms |
コンパイル使用メモリ | 195,964 KB |
実行使用メモリ | 102,400 KB |
最終ジャッジ日時 | 2024-04-21 22:32:13 |
合計ジャッジ時間 | 6,407 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 17 ms
11,520 KB |
testcase_04 | AC | 16 ms
11,520 KB |
testcase_05 | AC | 16 ms
11,392 KB |
testcase_06 | AC | 16 ms
11,520 KB |
testcase_07 | AC | 16 ms
11,392 KB |
testcase_08 | AC | 46 ms
27,136 KB |
testcase_09 | AC | 46 ms
27,264 KB |
testcase_10 | AC | 46 ms
27,264 KB |
testcase_11 | AC | 46 ms
27,136 KB |
testcase_12 | AC | 46 ms
27,264 KB |
testcase_13 | AC | 92 ms
50,688 KB |
testcase_14 | AC | 91 ms
50,816 KB |
testcase_15 | AC | 92 ms
50,688 KB |
testcase_16 | AC | 93 ms
50,816 KB |
testcase_17 | AC | 93 ms
50,688 KB |
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
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; constexpr int mod = 1000000007; int dp[5050][5050]; void mpl(int &x,int y) { x += y; if(x >= mod) x -= mod; } int main() { int N; cin >> N; vector<int>cnt(5000); for(int i = 0; i < N; i++) { int a; cin >> a; cnt[a]++; } dp[0][0] = 1; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { mpl(dp[i+1][j],dp[i][j]); mpl(dp[i+1][j+1],1ll*dp[i][j]*cnt[i]%mod); } } vector<int>f(N+1); f[0] = 1; for(int i = 1; i <= N; i++) { f[i] = 1ll*f[i-1]*i%mod; } int ans = 0; for(int i = 0; i <= N; i++) { if(i%2 == 0) { mpl(ans,1ll*dp[N][i]*f[N-i]%mod); } else { mpl(ans,mod-1ll*dp[N][i]*f[N-i]%mod); } } cout << ans << endl; }