#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int nmax=505;
vector<int> ans;
int dp[nmax*nmax],act[nmax*nmax],cate[nmax*nmax],ok[nmax*nmax];
int a[nmax];
int n,i,j,S,sum;
void add(int &a,int b,int mod)
{
a+=b;
if(a>=mod)
a-=mod;
}
void sub(int &a,int b,int mod)
{
a-=b;
if(a<0)
a+=mod;
}
void solve(int mod)
{
dp[0]=1;
for(i=1;i<=sum;i++)
dp[i]=0,cate[i]=0;
for(i=1;i<=n;i++)
for(j=sum/2-a[i];j>=0;j--)
add(dp[j+a[i]],dp[j],mod);
for(i=1;i<=n;i++)
{
for(j=sum/2;j>=0;j--)
act[j]=dp[j];
for(j=0;j<=sum/2-a[i];j++)
sub(act[j+a[i]],act[j],mod);
S=sum-a[i];
for(j=0;j<=S/2;j++)
if(act[j])
cate[S-2*j]++;
}
for(i=1;i<=sum;i++)
if(cate[i]==n)
ok[i]=1;
}
int main()
{
//freopen("data.in","r",stdin);
ios_base::sync_with_stdio(false);
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i],sum+=a[i];
solve(1000*1000*1000+7);
if(dp[sum/2]==0||sum%2)
{
cout<<"0";
return 0;
}
for(i=1;i<=sum;i++)
if(ok[i])
ans.push_back(i);
cout<<ans.size()<<'\n';
for(int i=0;i<ans.size();i++)
cout<<ans[i]<<' ';
return 0;
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:62:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<ans.size();i++)
~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
424 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
424 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
608 KB |
Output is correct |
11 |
Correct |
2 ms |
608 KB |
Output is correct |
12 |
Correct |
2 ms |
608 KB |
Output is correct |
13 |
Correct |
2 ms |
608 KB |
Output is correct |
14 |
Correct |
2 ms |
608 KB |
Output is correct |
15 |
Correct |
2 ms |
612 KB |
Output is correct |
16 |
Correct |
2 ms |
612 KB |
Output is correct |
17 |
Correct |
2 ms |
612 KB |
Output is correct |
18 |
Correct |
2 ms |
612 KB |
Output is correct |
19 |
Correct |
2 ms |
612 KB |
Output is correct |
20 |
Correct |
2 ms |
612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
424 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
608 KB |
Output is correct |
11 |
Correct |
2 ms |
608 KB |
Output is correct |
12 |
Correct |
2 ms |
608 KB |
Output is correct |
13 |
Correct |
2 ms |
608 KB |
Output is correct |
14 |
Correct |
2 ms |
608 KB |
Output is correct |
15 |
Correct |
2 ms |
612 KB |
Output is correct |
16 |
Correct |
2 ms |
612 KB |
Output is correct |
17 |
Correct |
2 ms |
612 KB |
Output is correct |
18 |
Correct |
2 ms |
612 KB |
Output is correct |
19 |
Correct |
2 ms |
612 KB |
Output is correct |
20 |
Correct |
2 ms |
612 KB |
Output is correct |
21 |
Correct |
3 ms |
612 KB |
Output is correct |
22 |
Correct |
3 ms |
612 KB |
Output is correct |
23 |
Correct |
2 ms |
624 KB |
Output is correct |
24 |
Correct |
3 ms |
640 KB |
Output is correct |
25 |
Correct |
4 ms |
768 KB |
Output is correct |
26 |
Correct |
5 ms |
784 KB |
Output is correct |
27 |
Correct |
4 ms |
784 KB |
Output is correct |
28 |
Correct |
4 ms |
784 KB |
Output is correct |
29 |
Correct |
4 ms |
800 KB |
Output is correct |
30 |
Correct |
4 ms |
800 KB |
Output is correct |
31 |
Correct |
4 ms |
800 KB |
Output is correct |
32 |
Correct |
1 ms |
804 KB |
Output is correct |
33 |
Correct |
4 ms |
804 KB |
Output is correct |
34 |
Correct |
4 ms |
804 KB |
Output is correct |
35 |
Correct |
4 ms |
928 KB |
Output is correct |
36 |
Correct |
3 ms |
928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
424 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
608 KB |
Output is correct |
11 |
Correct |
2 ms |
608 KB |
Output is correct |
12 |
Correct |
2 ms |
608 KB |
Output is correct |
13 |
Correct |
2 ms |
608 KB |
Output is correct |
14 |
Correct |
2 ms |
608 KB |
Output is correct |
15 |
Correct |
2 ms |
612 KB |
Output is correct |
16 |
Correct |
2 ms |
612 KB |
Output is correct |
17 |
Correct |
2 ms |
612 KB |
Output is correct |
18 |
Correct |
2 ms |
612 KB |
Output is correct |
19 |
Correct |
2 ms |
612 KB |
Output is correct |
20 |
Correct |
2 ms |
612 KB |
Output is correct |
21 |
Correct |
3 ms |
612 KB |
Output is correct |
22 |
Correct |
3 ms |
612 KB |
Output is correct |
23 |
Correct |
2 ms |
624 KB |
Output is correct |
24 |
Correct |
3 ms |
640 KB |
Output is correct |
25 |
Correct |
4 ms |
768 KB |
Output is correct |
26 |
Correct |
5 ms |
784 KB |
Output is correct |
27 |
Correct |
4 ms |
784 KB |
Output is correct |
28 |
Correct |
4 ms |
784 KB |
Output is correct |
29 |
Correct |
4 ms |
800 KB |
Output is correct |
30 |
Correct |
4 ms |
800 KB |
Output is correct |
31 |
Correct |
4 ms |
800 KB |
Output is correct |
32 |
Correct |
1 ms |
804 KB |
Output is correct |
33 |
Correct |
4 ms |
804 KB |
Output is correct |
34 |
Correct |
4 ms |
804 KB |
Output is correct |
35 |
Correct |
4 ms |
928 KB |
Output is correct |
36 |
Correct |
3 ms |
928 KB |
Output is correct |
37 |
Correct |
12 ms |
1068 KB |
Output is correct |
38 |
Correct |
12 ms |
1068 KB |
Output is correct |
39 |
Correct |
32 ms |
1580 KB |
Output is correct |
40 |
Correct |
23 ms |
1580 KB |
Output is correct |
41 |
Correct |
44 ms |
1728 KB |
Output is correct |
42 |
Correct |
20 ms |
1728 KB |
Output is correct |
43 |
Correct |
33 ms |
1852 KB |
Output is correct |
44 |
Correct |
37 ms |
1852 KB |
Output is correct |
45 |
Correct |
39 ms |
1852 KB |
Output is correct |
46 |
Correct |
19 ms |
1852 KB |
Output is correct |
47 |
Correct |
22 ms |
1852 KB |
Output is correct |
48 |
Correct |
39 ms |
1852 KB |
Output is correct |
49 |
Correct |
40 ms |
1852 KB |
Output is correct |
50 |
Correct |
21 ms |
1852 KB |
Output is correct |
51 |
Correct |
20 ms |
1852 KB |
Output is correct |
52 |
Correct |
45 ms |
1980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
424 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
608 KB |
Output is correct |
11 |
Correct |
2 ms |
608 KB |
Output is correct |
12 |
Correct |
2 ms |
608 KB |
Output is correct |
13 |
Correct |
2 ms |
608 KB |
Output is correct |
14 |
Correct |
2 ms |
608 KB |
Output is correct |
15 |
Correct |
2 ms |
612 KB |
Output is correct |
16 |
Correct |
2 ms |
612 KB |
Output is correct |
17 |
Correct |
2 ms |
612 KB |
Output is correct |
18 |
Correct |
2 ms |
612 KB |
Output is correct |
19 |
Correct |
2 ms |
612 KB |
Output is correct |
20 |
Correct |
2 ms |
612 KB |
Output is correct |
21 |
Correct |
3 ms |
612 KB |
Output is correct |
22 |
Correct |
3 ms |
612 KB |
Output is correct |
23 |
Correct |
2 ms |
624 KB |
Output is correct |
24 |
Correct |
3 ms |
640 KB |
Output is correct |
25 |
Correct |
4 ms |
768 KB |
Output is correct |
26 |
Correct |
5 ms |
784 KB |
Output is correct |
27 |
Correct |
4 ms |
784 KB |
Output is correct |
28 |
Correct |
4 ms |
784 KB |
Output is correct |
29 |
Correct |
4 ms |
800 KB |
Output is correct |
30 |
Correct |
4 ms |
800 KB |
Output is correct |
31 |
Correct |
4 ms |
800 KB |
Output is correct |
32 |
Correct |
1 ms |
804 KB |
Output is correct |
33 |
Correct |
4 ms |
804 KB |
Output is correct |
34 |
Correct |
4 ms |
804 KB |
Output is correct |
35 |
Correct |
4 ms |
928 KB |
Output is correct |
36 |
Correct |
3 ms |
928 KB |
Output is correct |
37 |
Correct |
12 ms |
1068 KB |
Output is correct |
38 |
Correct |
12 ms |
1068 KB |
Output is correct |
39 |
Correct |
32 ms |
1580 KB |
Output is correct |
40 |
Correct |
23 ms |
1580 KB |
Output is correct |
41 |
Correct |
44 ms |
1728 KB |
Output is correct |
42 |
Correct |
20 ms |
1728 KB |
Output is correct |
43 |
Correct |
33 ms |
1852 KB |
Output is correct |
44 |
Correct |
37 ms |
1852 KB |
Output is correct |
45 |
Correct |
39 ms |
1852 KB |
Output is correct |
46 |
Correct |
19 ms |
1852 KB |
Output is correct |
47 |
Correct |
22 ms |
1852 KB |
Output is correct |
48 |
Correct |
39 ms |
1852 KB |
Output is correct |
49 |
Correct |
40 ms |
1852 KB |
Output is correct |
50 |
Correct |
21 ms |
1852 KB |
Output is correct |
51 |
Correct |
20 ms |
1852 KB |
Output is correct |
52 |
Correct |
45 ms |
1980 KB |
Output is correct |
53 |
Correct |
34 ms |
1980 KB |
Output is correct |
54 |
Correct |
46 ms |
1980 KB |
Output is correct |
55 |
Correct |
90 ms |
2700 KB |
Output is correct |
56 |
Correct |
41 ms |
2700 KB |
Output is correct |
57 |
Correct |
94 ms |
2876 KB |
Output is correct |
58 |
Correct |
85 ms |
2876 KB |
Output is correct |
59 |
Correct |
63 ms |
2876 KB |
Output is correct |
60 |
Correct |
47 ms |
2876 KB |
Output is correct |
61 |
Correct |
71 ms |
2876 KB |
Output is correct |
62 |
Correct |
75 ms |
2876 KB |
Output is correct |
63 |
Correct |
79 ms |
2876 KB |
Output is correct |
64 |
Correct |
75 ms |
2876 KB |
Output is correct |
65 |
Correct |
38 ms |
2876 KB |
Output is correct |
66 |
Correct |
41 ms |
2876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
424 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
608 KB |
Output is correct |
11 |
Correct |
2 ms |
608 KB |
Output is correct |
12 |
Correct |
2 ms |
608 KB |
Output is correct |
13 |
Correct |
2 ms |
608 KB |
Output is correct |
14 |
Correct |
2 ms |
608 KB |
Output is correct |
15 |
Correct |
2 ms |
612 KB |
Output is correct |
16 |
Correct |
2 ms |
612 KB |
Output is correct |
17 |
Correct |
2 ms |
612 KB |
Output is correct |
18 |
Correct |
2 ms |
612 KB |
Output is correct |
19 |
Correct |
2 ms |
612 KB |
Output is correct |
20 |
Correct |
2 ms |
612 KB |
Output is correct |
21 |
Correct |
3 ms |
612 KB |
Output is correct |
22 |
Correct |
3 ms |
612 KB |
Output is correct |
23 |
Correct |
2 ms |
624 KB |
Output is correct |
24 |
Correct |
3 ms |
640 KB |
Output is correct |
25 |
Correct |
4 ms |
768 KB |
Output is correct |
26 |
Correct |
5 ms |
784 KB |
Output is correct |
27 |
Correct |
4 ms |
784 KB |
Output is correct |
28 |
Correct |
4 ms |
784 KB |
Output is correct |
29 |
Correct |
4 ms |
800 KB |
Output is correct |
30 |
Correct |
4 ms |
800 KB |
Output is correct |
31 |
Correct |
4 ms |
800 KB |
Output is correct |
32 |
Correct |
1 ms |
804 KB |
Output is correct |
33 |
Correct |
4 ms |
804 KB |
Output is correct |
34 |
Correct |
4 ms |
804 KB |
Output is correct |
35 |
Correct |
4 ms |
928 KB |
Output is correct |
36 |
Correct |
3 ms |
928 KB |
Output is correct |
37 |
Correct |
12 ms |
1068 KB |
Output is correct |
38 |
Correct |
12 ms |
1068 KB |
Output is correct |
39 |
Correct |
32 ms |
1580 KB |
Output is correct |
40 |
Correct |
23 ms |
1580 KB |
Output is correct |
41 |
Correct |
44 ms |
1728 KB |
Output is correct |
42 |
Correct |
20 ms |
1728 KB |
Output is correct |
43 |
Correct |
33 ms |
1852 KB |
Output is correct |
44 |
Correct |
37 ms |
1852 KB |
Output is correct |
45 |
Correct |
39 ms |
1852 KB |
Output is correct |
46 |
Correct |
19 ms |
1852 KB |
Output is correct |
47 |
Correct |
22 ms |
1852 KB |
Output is correct |
48 |
Correct |
39 ms |
1852 KB |
Output is correct |
49 |
Correct |
40 ms |
1852 KB |
Output is correct |
50 |
Correct |
21 ms |
1852 KB |
Output is correct |
51 |
Correct |
20 ms |
1852 KB |
Output is correct |
52 |
Correct |
45 ms |
1980 KB |
Output is correct |
53 |
Correct |
34 ms |
1980 KB |
Output is correct |
54 |
Correct |
46 ms |
1980 KB |
Output is correct |
55 |
Correct |
90 ms |
2700 KB |
Output is correct |
56 |
Correct |
41 ms |
2700 KB |
Output is correct |
57 |
Correct |
94 ms |
2876 KB |
Output is correct |
58 |
Correct |
85 ms |
2876 KB |
Output is correct |
59 |
Correct |
63 ms |
2876 KB |
Output is correct |
60 |
Correct |
47 ms |
2876 KB |
Output is correct |
61 |
Correct |
71 ms |
2876 KB |
Output is correct |
62 |
Correct |
75 ms |
2876 KB |
Output is correct |
63 |
Correct |
79 ms |
2876 KB |
Output is correct |
64 |
Correct |
75 ms |
2876 KB |
Output is correct |
65 |
Correct |
38 ms |
2876 KB |
Output is correct |
66 |
Correct |
41 ms |
2876 KB |
Output is correct |
67 |
Correct |
79 ms |
2876 KB |
Output is correct |
68 |
Correct |
128 ms |
2876 KB |
Output is correct |
69 |
Correct |
242 ms |
4772 KB |
Output is correct |
70 |
Correct |
146 ms |
4772 KB |
Output is correct |
71 |
Correct |
142 ms |
4772 KB |
Output is correct |
72 |
Correct |
137 ms |
4772 KB |
Output is correct |
73 |
Correct |
136 ms |
4772 KB |
Output is correct |
74 |
Correct |
259 ms |
4960 KB |
Output is correct |
75 |
Correct |
199 ms |
4960 KB |
Output is correct |
76 |
Correct |
268 ms |
5052 KB |
Output is correct |
77 |
Correct |
268 ms |
5132 KB |
Output is correct |