#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-a[i];j>=0;j--)
add(dp[j+a[i]],dp[j],mod);
for(i=1;i<=n;i++)
{
for(j=sum;j>=0;j--)
act[j]=dp[j];
for(j=0;j<=sum-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++)
~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
2 ms |
648 KB |
Output is correct |
12 |
Correct |
2 ms |
652 KB |
Output is correct |
13 |
Correct |
2 ms |
656 KB |
Output is correct |
14 |
Correct |
2 ms |
660 KB |
Output is correct |
15 |
Correct |
2 ms |
664 KB |
Output is correct |
16 |
Correct |
2 ms |
668 KB |
Output is correct |
17 |
Correct |
2 ms |
672 KB |
Output is correct |
18 |
Correct |
2 ms |
676 KB |
Output is correct |
19 |
Correct |
2 ms |
680 KB |
Output is correct |
20 |
Correct |
2 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
2 ms |
648 KB |
Output is correct |
12 |
Correct |
2 ms |
652 KB |
Output is correct |
13 |
Correct |
2 ms |
656 KB |
Output is correct |
14 |
Correct |
2 ms |
660 KB |
Output is correct |
15 |
Correct |
2 ms |
664 KB |
Output is correct |
16 |
Correct |
2 ms |
668 KB |
Output is correct |
17 |
Correct |
2 ms |
672 KB |
Output is correct |
18 |
Correct |
2 ms |
676 KB |
Output is correct |
19 |
Correct |
2 ms |
680 KB |
Output is correct |
20 |
Correct |
2 ms |
684 KB |
Output is correct |
21 |
Correct |
3 ms |
688 KB |
Output is correct |
22 |
Correct |
3 ms |
692 KB |
Output is correct |
23 |
Correct |
3 ms |
712 KB |
Output is correct |
24 |
Correct |
4 ms |
844 KB |
Output is correct |
25 |
Correct |
6 ms |
980 KB |
Output is correct |
26 |
Correct |
6 ms |
980 KB |
Output is correct |
27 |
Correct |
6 ms |
980 KB |
Output is correct |
28 |
Correct |
6 ms |
980 KB |
Output is correct |
29 |
Correct |
6 ms |
980 KB |
Output is correct |
30 |
Correct |
4 ms |
980 KB |
Output is correct |
31 |
Correct |
5 ms |
980 KB |
Output is correct |
32 |
Correct |
4 ms |
980 KB |
Output is correct |
33 |
Correct |
6 ms |
980 KB |
Output is correct |
34 |
Correct |
6 ms |
980 KB |
Output is correct |
35 |
Correct |
6 ms |
980 KB |
Output is correct |
36 |
Correct |
27 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
2 ms |
648 KB |
Output is correct |
12 |
Correct |
2 ms |
652 KB |
Output is correct |
13 |
Correct |
2 ms |
656 KB |
Output is correct |
14 |
Correct |
2 ms |
660 KB |
Output is correct |
15 |
Correct |
2 ms |
664 KB |
Output is correct |
16 |
Correct |
2 ms |
668 KB |
Output is correct |
17 |
Correct |
2 ms |
672 KB |
Output is correct |
18 |
Correct |
2 ms |
676 KB |
Output is correct |
19 |
Correct |
2 ms |
680 KB |
Output is correct |
20 |
Correct |
2 ms |
684 KB |
Output is correct |
21 |
Correct |
3 ms |
688 KB |
Output is correct |
22 |
Correct |
3 ms |
692 KB |
Output is correct |
23 |
Correct |
3 ms |
712 KB |
Output is correct |
24 |
Correct |
4 ms |
844 KB |
Output is correct |
25 |
Correct |
6 ms |
980 KB |
Output is correct |
26 |
Correct |
6 ms |
980 KB |
Output is correct |
27 |
Correct |
6 ms |
980 KB |
Output is correct |
28 |
Correct |
6 ms |
980 KB |
Output is correct |
29 |
Correct |
6 ms |
980 KB |
Output is correct |
30 |
Correct |
4 ms |
980 KB |
Output is correct |
31 |
Correct |
5 ms |
980 KB |
Output is correct |
32 |
Correct |
4 ms |
980 KB |
Output is correct |
33 |
Correct |
6 ms |
980 KB |
Output is correct |
34 |
Correct |
6 ms |
980 KB |
Output is correct |
35 |
Correct |
6 ms |
980 KB |
Output is correct |
36 |
Correct |
27 ms |
980 KB |
Output is correct |
37 |
Correct |
17 ms |
1196 KB |
Output is correct |
38 |
Correct |
18 ms |
1200 KB |
Output is correct |
39 |
Correct |
58 ms |
1716 KB |
Output is correct |
40 |
Correct |
37 ms |
1716 KB |
Output is correct |
41 |
Correct |
75 ms |
1972 KB |
Output is correct |
42 |
Correct |
34 ms |
1972 KB |
Output is correct |
43 |
Correct |
53 ms |
2076 KB |
Output is correct |
44 |
Correct |
61 ms |
2092 KB |
Output is correct |
45 |
Correct |
55 ms |
2092 KB |
Output is correct |
46 |
Correct |
31 ms |
2092 KB |
Output is correct |
47 |
Correct |
37 ms |
2092 KB |
Output is correct |
48 |
Correct |
62 ms |
2092 KB |
Output is correct |
49 |
Correct |
62 ms |
2092 KB |
Output is correct |
50 |
Correct |
36 ms |
2092 KB |
Output is correct |
51 |
Correct |
30 ms |
2092 KB |
Output is correct |
52 |
Correct |
73 ms |
2388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
2 ms |
648 KB |
Output is correct |
12 |
Correct |
2 ms |
652 KB |
Output is correct |
13 |
Correct |
2 ms |
656 KB |
Output is correct |
14 |
Correct |
2 ms |
660 KB |
Output is correct |
15 |
Correct |
2 ms |
664 KB |
Output is correct |
16 |
Correct |
2 ms |
668 KB |
Output is correct |
17 |
Correct |
2 ms |
672 KB |
Output is correct |
18 |
Correct |
2 ms |
676 KB |
Output is correct |
19 |
Correct |
2 ms |
680 KB |
Output is correct |
20 |
Correct |
2 ms |
684 KB |
Output is correct |
21 |
Correct |
3 ms |
688 KB |
Output is correct |
22 |
Correct |
3 ms |
692 KB |
Output is correct |
23 |
Correct |
3 ms |
712 KB |
Output is correct |
24 |
Correct |
4 ms |
844 KB |
Output is correct |
25 |
Correct |
6 ms |
980 KB |
Output is correct |
26 |
Correct |
6 ms |
980 KB |
Output is correct |
27 |
Correct |
6 ms |
980 KB |
Output is correct |
28 |
Correct |
6 ms |
980 KB |
Output is correct |
29 |
Correct |
6 ms |
980 KB |
Output is correct |
30 |
Correct |
4 ms |
980 KB |
Output is correct |
31 |
Correct |
5 ms |
980 KB |
Output is correct |
32 |
Correct |
4 ms |
980 KB |
Output is correct |
33 |
Correct |
6 ms |
980 KB |
Output is correct |
34 |
Correct |
6 ms |
980 KB |
Output is correct |
35 |
Correct |
6 ms |
980 KB |
Output is correct |
36 |
Correct |
27 ms |
980 KB |
Output is correct |
37 |
Correct |
17 ms |
1196 KB |
Output is correct |
38 |
Correct |
18 ms |
1200 KB |
Output is correct |
39 |
Correct |
58 ms |
1716 KB |
Output is correct |
40 |
Correct |
37 ms |
1716 KB |
Output is correct |
41 |
Correct |
75 ms |
1972 KB |
Output is correct |
42 |
Correct |
34 ms |
1972 KB |
Output is correct |
43 |
Correct |
53 ms |
2076 KB |
Output is correct |
44 |
Correct |
61 ms |
2092 KB |
Output is correct |
45 |
Correct |
55 ms |
2092 KB |
Output is correct |
46 |
Correct |
31 ms |
2092 KB |
Output is correct |
47 |
Correct |
37 ms |
2092 KB |
Output is correct |
48 |
Correct |
62 ms |
2092 KB |
Output is correct |
49 |
Correct |
62 ms |
2092 KB |
Output is correct |
50 |
Correct |
36 ms |
2092 KB |
Output is correct |
51 |
Correct |
30 ms |
2092 KB |
Output is correct |
52 |
Correct |
73 ms |
2388 KB |
Output is correct |
53 |
Correct |
56 ms |
2388 KB |
Output is correct |
54 |
Correct |
78 ms |
2388 KB |
Output is correct |
55 |
Correct |
147 ms |
3148 KB |
Output is correct |
56 |
Correct |
71 ms |
3148 KB |
Output is correct |
57 |
Correct |
161 ms |
3344 KB |
Output is correct |
58 |
Correct |
83 ms |
3344 KB |
Output is correct |
59 |
Correct |
102 ms |
3344 KB |
Output is correct |
60 |
Correct |
80 ms |
3344 KB |
Output is correct |
61 |
Correct |
117 ms |
3344 KB |
Output is correct |
62 |
Correct |
117 ms |
3344 KB |
Output is correct |
63 |
Correct |
124 ms |
3344 KB |
Output is correct |
64 |
Correct |
123 ms |
3344 KB |
Output is correct |
65 |
Correct |
62 ms |
3344 KB |
Output is correct |
66 |
Correct |
65 ms |
3344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
2 ms |
648 KB |
Output is correct |
12 |
Correct |
2 ms |
652 KB |
Output is correct |
13 |
Correct |
2 ms |
656 KB |
Output is correct |
14 |
Correct |
2 ms |
660 KB |
Output is correct |
15 |
Correct |
2 ms |
664 KB |
Output is correct |
16 |
Correct |
2 ms |
668 KB |
Output is correct |
17 |
Correct |
2 ms |
672 KB |
Output is correct |
18 |
Correct |
2 ms |
676 KB |
Output is correct |
19 |
Correct |
2 ms |
680 KB |
Output is correct |
20 |
Correct |
2 ms |
684 KB |
Output is correct |
21 |
Correct |
3 ms |
688 KB |
Output is correct |
22 |
Correct |
3 ms |
692 KB |
Output is correct |
23 |
Correct |
3 ms |
712 KB |
Output is correct |
24 |
Correct |
4 ms |
844 KB |
Output is correct |
25 |
Correct |
6 ms |
980 KB |
Output is correct |
26 |
Correct |
6 ms |
980 KB |
Output is correct |
27 |
Correct |
6 ms |
980 KB |
Output is correct |
28 |
Correct |
6 ms |
980 KB |
Output is correct |
29 |
Correct |
6 ms |
980 KB |
Output is correct |
30 |
Correct |
4 ms |
980 KB |
Output is correct |
31 |
Correct |
5 ms |
980 KB |
Output is correct |
32 |
Correct |
4 ms |
980 KB |
Output is correct |
33 |
Correct |
6 ms |
980 KB |
Output is correct |
34 |
Correct |
6 ms |
980 KB |
Output is correct |
35 |
Correct |
6 ms |
980 KB |
Output is correct |
36 |
Correct |
27 ms |
980 KB |
Output is correct |
37 |
Correct |
17 ms |
1196 KB |
Output is correct |
38 |
Correct |
18 ms |
1200 KB |
Output is correct |
39 |
Correct |
58 ms |
1716 KB |
Output is correct |
40 |
Correct |
37 ms |
1716 KB |
Output is correct |
41 |
Correct |
75 ms |
1972 KB |
Output is correct |
42 |
Correct |
34 ms |
1972 KB |
Output is correct |
43 |
Correct |
53 ms |
2076 KB |
Output is correct |
44 |
Correct |
61 ms |
2092 KB |
Output is correct |
45 |
Correct |
55 ms |
2092 KB |
Output is correct |
46 |
Correct |
31 ms |
2092 KB |
Output is correct |
47 |
Correct |
37 ms |
2092 KB |
Output is correct |
48 |
Correct |
62 ms |
2092 KB |
Output is correct |
49 |
Correct |
62 ms |
2092 KB |
Output is correct |
50 |
Correct |
36 ms |
2092 KB |
Output is correct |
51 |
Correct |
30 ms |
2092 KB |
Output is correct |
52 |
Correct |
73 ms |
2388 KB |
Output is correct |
53 |
Correct |
56 ms |
2388 KB |
Output is correct |
54 |
Correct |
78 ms |
2388 KB |
Output is correct |
55 |
Correct |
147 ms |
3148 KB |
Output is correct |
56 |
Correct |
71 ms |
3148 KB |
Output is correct |
57 |
Correct |
161 ms |
3344 KB |
Output is correct |
58 |
Correct |
83 ms |
3344 KB |
Output is correct |
59 |
Correct |
102 ms |
3344 KB |
Output is correct |
60 |
Correct |
80 ms |
3344 KB |
Output is correct |
61 |
Correct |
117 ms |
3344 KB |
Output is correct |
62 |
Correct |
117 ms |
3344 KB |
Output is correct |
63 |
Correct |
124 ms |
3344 KB |
Output is correct |
64 |
Correct |
123 ms |
3344 KB |
Output is correct |
65 |
Correct |
62 ms |
3344 KB |
Output is correct |
66 |
Correct |
65 ms |
3344 KB |
Output is correct |
67 |
Correct |
123 ms |
3344 KB |
Output is correct |
68 |
Correct |
211 ms |
3344 KB |
Output is correct |
69 |
Correct |
396 ms |
5476 KB |
Output is correct |
70 |
Correct |
261 ms |
5476 KB |
Output is correct |
71 |
Correct |
233 ms |
5476 KB |
Output is correct |
72 |
Correct |
226 ms |
5476 KB |
Output is correct |
73 |
Correct |
231 ms |
5476 KB |
Output is correct |
74 |
Correct |
452 ms |
5712 KB |
Output is correct |
75 |
Correct |
345 ms |
5712 KB |
Output is correct |
76 |
Correct |
452 ms |
6116 KB |
Output is correct |
77 |
Correct |
448 ms |
6116 KB |
Output is correct |