QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624116#9436. Some Sum of Subsetucup-team4975WA 8ms39352kbC++231.4kb2024-10-09 14:59:562024-10-09 14:59:56

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 14:59:56]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:39352kb
  • [2024-10-09 14:59:56]
  • 提交

answer

#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#define FINISH cerr << "FINISH" << endl;
#define debug(x) cerr << #x << " == " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 3030;
int C[N][N];
void solve()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1, 0), ans(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(next(a.begin()), a.end(), [&](int x, int y) { return x > y; });
	vector dp(n + 1, vector<int>(m + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		vector<int> now(m + 1, 0);
		for (int j = 0; j <= m; j++) {
			dp[i + 1][j] += dp[i][j] %= mod;
			dp[i + 1][min(j + a[i + 1], m)] += dp[i][j] %= mod;
			now[min(j + a[i + 1], m)] += dp[i][j] %= mod;
		}
		for (int k = 0; k <= n - i - 1; k++) {
			int r = (1ll * C[n - i - 1][k] * now[m]) % mod;
			ans[k] += r %= mod;
		}
	}
	for (int i = 0; i <= n; i++) {
		cout << ans[i] << " ";
	}
	cout << el;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	C[0][0] = 1;
	for (int i = 1; i <= 3000; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}
	int T = 1;
	// cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 38324kb

input:

4 7
3 1 5 2

output:

6 4 1 0 0 

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 7ms
memory: 38040kb

input:

1 5
7

output:

1 0 

result:

ok 2 tokens

Test #3:

score: 0
Accepted
time: 4ms
memory: 38272kb

input:

9 18
1 9 5 6 2 7 1 4 8

output:

346 309 230 126 46 10 1 0 0 0 

result:

ok 10 tokens

Test #4:

score: 0
Accepted
time: 8ms
memory: 38108kb

input:

1 1467
556

output:

0 0 

result:

ok 2 tokens

Test #5:

score: 0
Accepted
time: 4ms
memory: 39352kb

input:

1 1753
2514

output:

1 0 

result:

ok 2 tokens

Test #6:

score: 0
Accepted
time: 4ms
memory: 38500kb

input:

1 1182
1182

output:

1 0 

result:

ok 2 tokens

Test #7:

score: 0
Accepted
time: 8ms
memory: 38396kb

input:

2 1741
955 835

output:

1 0 0 

result:

ok 3 tokens

Test #8:

score: 0
Accepted
time: 8ms
memory: 38388kb

input:

2 1481
2004 1570

output:

3 1 0 

result:

ok 3 tokens

Test #9:

score: 0
Accepted
time: 3ms
memory: 38708kb

input:

2 1336
1336 1336

output:

3 1 0 

result:

ok 3 tokens

Test #10:

score: 0
Accepted
time: 4ms
memory: 38528kb

input:

12 400
2163 2729 1322 2787 2404 1068 1502 746 898 2057 1771 502

output:

4095 4083 4017 3797 3302 2510 1586 794 299 79 13 1 0 

result:

ok 13 tokens

Test #11:

score: -100
Wrong Answer
time: 8ms
memory: 39140kb

input:

42 1609
532 722 2650 2889 2260 659 1831 401 2779 1262 2185 1479 515 552 1627 637 1080 580 1589 2154 2650 219 2924 1712 311 2609 1062 968 1357 1310 1942 2419 2465 300 2546 2537 2967 1197 2271 1551 999 2531

output:

-1820332604 176155708 176153358 -1124098259 -1124229166 -1427117788 564029435 -461342328 -579550110 -1025591135 -500604187 1208359341 -865409144 -1427853949 -80748857 1071354758 572233917 -837598442 840275951 582182135 886416719 1680492920 1288472827 -571846419 -890466507 -1998328001 497235938 -3472...

result:

wrong answer 1st words differ - expected: '780135870', found: '-1820332604'