結果

問題 No.243 出席番号(2)
ユーザー piyoko_212piyoko_212
提出日時 2015-12-26 01:01:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 34,824 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 03:54:03
合計ジャッジ時間 4,360 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 0 ms
4,348 KB
testcase_03 AC 11 ms
4,348 KB
testcase_04 AC 11 ms
4,348 KB
testcase_05 AC 12 ms
4,348 KB
testcase_06 AC 11 ms
4,348 KB
testcase_07 AC 12 ms
4,348 KB
testcase_08 AC 42 ms
4,348 KB
testcase_09 AC 42 ms
4,348 KB
testcase_10 AC 42 ms
4,348 KB
testcase_11 AC 42 ms
4,348 KB
testcase_12 AC 42 ms
4,348 KB
testcase_13 AC 93 ms
4,348 KB
testcase_14 AC 93 ms
4,348 KB
testcase_15 AC 94 ms
4,348 KB
testcase_16 AC 93 ms
4,348 KB
testcase_17 AC 93 ms
4,348 KB
testcase_18 AC 165 ms
4,348 KB
testcase_19 AC 164 ms
4,348 KB
testcase_20 AC 165 ms
4,348 KB
testcase_21 AC 165 ms
4,348 KB
testcase_22 AC 165 ms
4,348 KB
testcase_23 AC 258 ms
4,348 KB
testcase_24 AC 257 ms
4,348 KB
testcase_25 AC 260 ms
4,348 KB
testcase_26 AC 257 ms
4,348 KB
testcase_27 AC 258 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 0 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%d",&a);
      |         ~~~~~^~~~~~~~~
main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                 scanf("%d",b+i);
      |                 ~~~~~^~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
int b[5100];
int c[5100];
long long dp[5100];
long long fact[5100];
int main(){
	int M=5100;
	fact[0]=1;
	for(int i=1;i<M;i++)fact[i]=fact[i-1]*i%mod;
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
		c[b[i]]++;
	}
	dp[0]=1;
	for(int i=0;i<a;i++){
		for(int j=a-1;j>=0;j--){
			dp[j+1]=(dp[j+1]+dp[j]*c[i])%mod;
		}
	}
	long long ret=0;
	for(int i=0;i<=a;i++){
		if(i%2){
			ret=(ret+mod-dp[i]*fact[a-i]%mod)%mod;
		}else{
			ret=(ret+dp[i]*fact[a-i])%mod;
		}
	}
	printf("%lld\n",ret);
}
0