QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#762312#9443. Left Equals RightChtholly_Nephren#WA 1ms3984kbC++20685b2024-11-19 14:35:112024-11-19 14:35:11

Judging History

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

  • [2024-11-19 14:35:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3984kb
  • [2024-11-19 14:35:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, mx = 1e4;
int n, s, ans, a[105], fac[105], dp[10005], f[105][10005];
void add(int &x, int v) {
	(x += v) >= mod ? (x -= mod) : 0;
	return;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n, fac[0] = 1;
	for(int i = 1; i <= n; i++)
		cin >> a[i], s += a[i], fac[i] = 1ll * fac[i - 1] * i % mod;
	f[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = i - 1; ~j; j--)
			for(int k = mx; k >= a[i]; k--)
				add(f[j + 1][k], f[j][k - a[i]]);
	for(int i = 0; i < n; i++)
		add(ans, 1ll * f[i][s >> 1] * fac[i] % mod * fac[n - i] % mod);
	cout << ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3792kb

input:

3
4 9 5

output:

4

result:

ok "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

2
100 100

output:

2

result:

ok "2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

8
3 2 6 3 1 2 4 5

output:

11520

result:

ok "11520"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

2
93 93

output:

2

result:

ok "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

2
62 45

output:

0

result:

ok "0"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3720kb

input:

3
32 68 36

output:

4

result:

ok "4"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

3
27 2 25

output:

4

result:

ok "4"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3984kb

input:

10
38 27 36 88 77 25 73 44 11 21

output:

126720

result:

ok "126720"

Test #9:

score: -100
Wrong Answer
time: 1ms
memory: 3984kb

input:

10
93 78 29 81 14 20 18 71 85 48

output:

60480

result:

wrong answer 1st words differ - expected: '0', found: '60480'