UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188295#3316. 平均(average)gaojieming1000ms1264kbC++11805b2023-10-03 08:33:162023-10-03 12:47:31

answer

#include<bits/stdc++.h>
#define ll long long
#define il inline
#define pn putchar('\n')
#define maxint 2147483647
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define maxn 55
#define int ll
using namespace std;
int n,A,minn,maxx;
int a[maxn],f[maxn*maxn*2],bac[maxn*maxn*2];
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #endif
    scanf("%lld%lld",&n,&A);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        a[i]-=A;
    }
    f[2500]=1;
    for(int i=1;i<=n;i++)
    {
        memcpy(bac,f,sizeof f);
        for(int j=minn+2500;j<=maxx+2500;j++)
            f[j+a[i]]+=bac[j];
        if(a[i]<0)
            minn+=a[i];
        else
            maxx+=a[i];
    }
    printf("%lld",f[2500]-1);
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

16 32
45 36 41 5 49 11 11 34 41 11 19 36 39 47 25 36

output:

756

result:

ok single line: '756'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

15 9
42 38 15 35 27 26 7 17 1 13 46 12 24 33 48

output:

2

result:

ok single line: '2'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

15 46
49 9 2 22 24 35 49 40 27 10 30 43 50 35 46

output:

7

result:

ok single line: '7'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

10 44
33 38 15 4 15 21 8 13 18 10

output:

0

result:

ok single line: '0'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

50 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1125899906842623

result:

ok single line: '1125899906842623'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1264kb

input:

50 1
50 50 1 1 1 50 1 50 50 50 50 50 1 1 1 1 50 1 1 50 50 50 50 1 1 1 1 1 1 1 1 1 50 50 1 1 50 50 1 ...

output:

33554431

result:

ok single line: '33554431'

Test #7:

score: 10
Accepted
time: 0ms
memory: 1256kb

input:

43 21
38 40 25 5 16 16 18 7 2 12 4 4 26 17 3 46 46 34 50 8 48 14 44 42 45 6 32 33 42 1 11 11 45 8 7 ...

output:

17632158863

result:

ok single line: '17632158863'

Test #8:

score: 10
Accepted
time: 0ms
memory: 1256kb

input:

41 10
40 36 34 17 29 46 12 10 16 47 36 25 8 11 30 15 50 48 30 25 10 34 39 2 45 27 48 36 44 34 34 12 ...

output:

267

result:

ok single line: '267'

Test #9:

score: 10
Accepted
time: 0ms
memory: 1256kb

input:

33 50
49 9 2 22 24 35 49 40 27 10 30 43 50 35 2 35 46 49 49 47 29 28 34 31 12 4 4 2 9 35 30 9 39

output:

1

result:

ok single line: '1'

Test #10:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

33 44
48 5 35 12 8 30 20 29 50 16 33 38 15 4 15 21 8 13 18 10 6 26 8 20 6 32 1 47 16 12 44 50 9

output:

15

result:

ok single line: '15'

Extra Test:

score: 0
Extra Test Passed