結果

問題 No.243 出席番号(2)
ユーザー 37zigen37zigen
提出日時 2018-05-04 05:37:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 982 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 74,012 KB
実行使用メモリ 61,624 KB
最終ジャッジ日時 2023-09-10 09:29:13
合計ジャッジ時間 12,330 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,800 KB
testcase_01 AC 123 ms
55,788 KB
testcase_02 AC 124 ms
56,056 KB
testcase_03 AC 223 ms
57,072 KB
testcase_04 AC 224 ms
56,768 KB
testcase_05 AC 227 ms
56,896 KB
testcase_06 AC 226 ms
56,548 KB
testcase_07 WA -
testcase_08 AC 257 ms
59,112 KB
testcase_09 AC 270 ms
59,232 KB
testcase_10 AC 304 ms
59,828 KB
testcase_11 AC 240 ms
58,756 KB
testcase_12 WA -
testcase_13 AC 307 ms
59,980 KB
testcase_14 AC 311 ms
59,996 KB
testcase_15 AC 310 ms
59,984 KB
testcase_16 AC 312 ms
59,500 KB
testcase_17 WA -
testcase_18 AC 341 ms
60,900 KB
testcase_19 AC 339 ms
60,056 KB
testcase_20 AC 337 ms
60,620 KB
testcase_21 AC 336 ms
59,908 KB
testcase_22 WA -
testcase_23 AC 344 ms
59,988 KB
testcase_24 AC 346 ms
60,444 KB
testcase_25 AC 371 ms
60,296 KB
testcase_26 AC 345 ms
60,024 KB
testcase_27 AC 345 ms
60,460 KB
testcase_28 AC 123 ms
55,948 KB
testcase_29 AC 125 ms
56,024 KB
testcase_30 AC 127 ms
55,740 KB
testcase_31 AC 134 ms
54,092 KB
testcase_32 AC 134 ms
55,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	final long MOD = 1_000_000_000 + 7;
	long[] fac = new long[10000];
	{
		fac[0] = 1;
		for (int i = 1; i < fac.length; ++i)
			fac[i] = fac[i - 1] * i % MOD;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] cnt = new int[5000];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
			++cnt[A[i]];
		}
		long[] f = new long[N + 1];
		f[0] = 1;
		for (int i = 0; i < cnt.length; ++i) {
			for (int j = N - 1; j >= 0; --j) {
				f[j + 1] += f[j] * cnt[i];
				f[j + 1] %= MOD;
			}
		}
		long ans = 0;

		for (int i = 0; i < f.length; ++i) {
			ans += fac[N - i] * f[i] % MOD * (i % 2 == 0 ? 1 : -1);
			ans = (ans + MOD) % MOD;
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0