답안 #863071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
863071 2023-10-19T14:32:54 Z TAhmed33 Magneti (COCI21_magneti) C++
110 / 110
89 ms 66648 KB
#include <bits/stdc++.h>
using namespace std;
int n, l, x;
const int MOD = 1e9 + 7;
int nCr[30500][500];
int dp1[100001][51];
int dp2[100001][51];
int add (int a, int b) {
	a += b; if (a >= MOD) a -= MOD;
	return a;
}
int sub (int a, int b) {
	a -= b; if (a < 0) a += MOD;
	return a;
}
int mul (int a, int b) {
	return (a * 1ll * b) % MOD;
}
int arr[51];
int main () {
	cin >> n >> l;
	for (int i = 0; i < 30500; i++) {
		for (int j = 0; j <= min(499, i); j++) {
			if (j == 0 || j == i) {
				nCr[i][j] = 1;
			} else {
				nCr[i][j] = add(nCr[i - 1][j], nCr[i - 1][j - 1]);
			}
		}
	}
	for (int i = 1; i <= n; i++) cin >> arr[i];
	sort(arr + 1, arr + n + 1);
	dp1[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= l; j++) {
			for (int k = 1; k <= i; k++) {
				dp2[j][k] = 0;
				if (2 * arr[i] - 1 <= j) dp2[j][k] = add(dp2[j][k], mul(mul(k + 1, k), dp1[j - 2 * arr[i] + 1][k + 1]));
				dp2[j][k] = add(dp2[j][k], dp1[j - 1][k - 1]);
				if (arr[i] <= j) dp2[j][k] = add(dp2[j][k], mul(2 * k, dp1[j - arr[i]][k]));
			}
		}
		for (int j = 0; j <= l; j++) {
			for (int k = 0; k <= n; k++) {
				dp1[j][k] = dp2[j][k];
			}
		}
	}
	//for (int i = 1; i <= l; i++) cout << dp[n][i][1] << '\n';
	int sum = 0;
	for (int i = 1; i <= l; i++) sum = add(sum, mul(dp1[i][1], nCr[n - i + l][n]));
	cout << sum << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 66648 KB Output is correct
2 Correct 22 ms 62808 KB Output is correct
3 Correct 26 ms 66000 KB Output is correct
4 Correct 24 ms 66140 KB Output is correct
5 Correct 26 ms 65108 KB Output is correct
6 Correct 42 ms 66140 KB Output is correct
7 Correct 38 ms 65372 KB Output is correct
8 Correct 22 ms 65108 KB Output is correct
9 Correct 35 ms 65364 KB Output is correct
10 Correct 23 ms 65108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 66396 KB Output is correct
2 Correct 23 ms 65264 KB Output is correct
3 Correct 26 ms 66396 KB Output is correct
4 Correct 23 ms 65880 KB Output is correct
5 Correct 27 ms 66280 KB Output is correct
6 Correct 23 ms 65112 KB Output is correct
7 Correct 26 ms 66308 KB Output is correct
8 Correct 25 ms 65268 KB Output is correct
9 Correct 23 ms 65360 KB Output is correct
10 Correct 23 ms 65108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 62800 KB Output is correct
2 Correct 22 ms 62812 KB Output is correct
3 Correct 23 ms 62756 KB Output is correct
4 Correct 22 ms 62812 KB Output is correct
5 Correct 23 ms 62736 KB Output is correct
6 Correct 23 ms 62812 KB Output is correct
7 Correct 27 ms 63060 KB Output is correct
8 Correct 22 ms 62812 KB Output is correct
9 Correct 23 ms 62812 KB Output is correct
10 Correct 22 ms 62804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 66648 KB Output is correct
2 Correct 22 ms 62808 KB Output is correct
3 Correct 26 ms 66000 KB Output is correct
4 Correct 24 ms 66140 KB Output is correct
5 Correct 26 ms 65108 KB Output is correct
6 Correct 42 ms 66140 KB Output is correct
7 Correct 38 ms 65372 KB Output is correct
8 Correct 22 ms 65108 KB Output is correct
9 Correct 35 ms 65364 KB Output is correct
10 Correct 23 ms 65108 KB Output is correct
11 Correct 26 ms 66396 KB Output is correct
12 Correct 23 ms 65264 KB Output is correct
13 Correct 26 ms 66396 KB Output is correct
14 Correct 23 ms 65880 KB Output is correct
15 Correct 27 ms 66280 KB Output is correct
16 Correct 23 ms 65112 KB Output is correct
17 Correct 26 ms 66308 KB Output is correct
18 Correct 25 ms 65268 KB Output is correct
19 Correct 23 ms 65360 KB Output is correct
20 Correct 23 ms 65108 KB Output is correct
21 Correct 23 ms 62800 KB Output is correct
22 Correct 22 ms 62812 KB Output is correct
23 Correct 23 ms 62756 KB Output is correct
24 Correct 22 ms 62812 KB Output is correct
25 Correct 23 ms 62736 KB Output is correct
26 Correct 23 ms 62812 KB Output is correct
27 Correct 27 ms 63060 KB Output is correct
28 Correct 22 ms 62812 KB Output is correct
29 Correct 23 ms 62812 KB Output is correct
30 Correct 22 ms 62804 KB Output is correct
31 Correct 86 ms 66300 KB Output is correct
32 Correct 61 ms 65616 KB Output is correct
33 Correct 88 ms 66396 KB Output is correct
34 Correct 37 ms 65624 KB Output is correct
35 Correct 85 ms 66396 KB Output is correct
36 Correct 26 ms 65872 KB Output is correct
37 Correct 86 ms 66396 KB Output is correct
38 Correct 32 ms 65132 KB Output is correct
39 Correct 87 ms 66400 KB Output is correct
40 Correct 41 ms 66244 KB Output is correct
41 Correct 85 ms 66396 KB Output is correct
42 Correct 23 ms 65000 KB Output is correct
43 Correct 84 ms 66404 KB Output is correct
44 Correct 29 ms 65620 KB Output is correct
45 Correct 85 ms 66388 KB Output is correct
46 Correct 23 ms 66136 KB Output is correct
47 Correct 33 ms 65884 KB Output is correct
48 Correct 27 ms 65360 KB Output is correct
49 Correct 24 ms 65884 KB Output is correct
50 Correct 22 ms 62812 KB Output is correct