QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#629157#9443. Left Equals RighthuaxiamengjinWA 1ms5796kbC++14835b2024-10-11 06:58:062024-10-11 06:58:06

Judging History

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

  • [2024-10-11 06:58:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5796kb
  • [2024-10-11 06:58:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int NN=998244353;
int n,a[100100];
int ans;
int f[2][101][50050];
int sum;
int p[100100];
signed main(){
    cin>>n;
    for (int i=1;i<=n;i++)
    cin>>a[i],sum+=a[i];
    sum/=2;
    f[0][0][0]=1;
    for (int i=1;i<=n;i++){
        int now=i&1,pre=now^1;
        for (int j=0;j<=n;j++) 
        for (int k=0;k<=sum;k++){
            f[now][j][k]=(f[now][j][k]+f[pre][j][k])%NN;
            if(k+a[i]<=sum&&j)f[now][j][k+a[i]]=(f[now][j][k+a[i]]+f[pre][j-1][k])%NN;
        }
        for (int j=0;j<=n;j++)
        for (int k=0;k<=sum;k++)
        f[pre][j][k]=0;
    }
    p[0]=1;
    for (int i=1;i<=n;i++)
    p[i]=p[i-1]*i%NN;
    for(int i=0;i<=n;i++)
    ans=(ans+f[n&1][i][sum]*p[i]%NN*p[n-i])%NN;
    cout<<ans<<"\n";
}

詳細信息

Test #1:

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

input:

3
4 9 5

output:

4

result:

ok "4"

Test #2:

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

input:

2
100 100

output:

2

result:

ok "2"

Test #3:

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

input:

8
3 2 6 3 1 2 4 5

output:

11520

result:

ok "11520"

Test #4:

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

input:

2
93 93

output:

2

result:

ok "2"

Test #5:

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

input:

2
62 45

output:

0

result:

ok "0"

Test #6:

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

input:

3
32 68 36

output:

4

result:

ok "4"

Test #7:

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

input:

3
27 2 25

output:

4

result:

ok "4"

Test #8:

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

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: 3760kb

input:

10
93 78 29 81 14 20 18 71 85 48

output:

60480

result:

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