#include<bits/stdc++.h>
using namespace std;
const int maxn = 503;
bitset <250006> ans;
bitset <250006> tek;
bitset <250006> newtek;
int i,j,p,q,n,m,k,sum;
int a[maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(i=1; i<=n; i++)
{
cin>>a[i];
sum+=a[i];
}
if(sum%2!=0)
{
cout<<0<<endl;
return 0;
}
for(i=2;i<=n;i++)
{
if(a[i]%2!=a[i-1]%2)
{
cout<<0<<endl;
return 0;
}
}
bitset <250006> tek;
tek.set(0);
tek[0]=true;
for(i=1;i<=n;i++)
{
tek|=(tek<<a[i]);
}
if(!tek[sum/2])
{
cout<<0<<endl;
return 0;
}
for(i=1;i<sum;i++)
ans[i]=1;
tek.set(false);
for(i=1;i<=n;i++)
{
///bez i
bitset <250006> tek;
tek[0]=1;
for(j=1;j<=n;j++)
{
if(j==i)continue;
tek|=(tek<<(2*a[j]));
}
tek=(tek<<(a[i]));
tek[0]=1;
ans&=tek;
}
int br = 0;
for(i=1;i<sum;i++)
if(ans[i])br++;
cout<<br<<endl;
for(i=sum-1;i>=1;i--)
{
if(ans[i])
cout<<sum-i<<" ";
}
return 0;
}
/**
4
1 3 1 5
4
200 200 200 200
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
448 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
448 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
448 KB |
Output is correct |
10 |
Correct |
7 ms |
468 KB |
Output is correct |
11 |
Correct |
8 ms |
468 KB |
Output is correct |
12 |
Correct |
7 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
468 KB |
Output is correct |
15 |
Correct |
6 ms |
468 KB |
Output is correct |
16 |
Correct |
7 ms |
448 KB |
Output is correct |
17 |
Correct |
3 ms |
468 KB |
Output is correct |
18 |
Correct |
5 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
7 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
448 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
448 KB |
Output is correct |
10 |
Correct |
7 ms |
468 KB |
Output is correct |
11 |
Correct |
8 ms |
468 KB |
Output is correct |
12 |
Correct |
7 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
468 KB |
Output is correct |
15 |
Correct |
6 ms |
468 KB |
Output is correct |
16 |
Correct |
7 ms |
448 KB |
Output is correct |
17 |
Correct |
3 ms |
468 KB |
Output is correct |
18 |
Correct |
5 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
7 ms |
476 KB |
Output is correct |
21 |
Correct |
32 ms |
468 KB |
Output is correct |
22 |
Correct |
46 ms |
468 KB |
Output is correct |
23 |
Correct |
20 ms |
468 KB |
Output is correct |
24 |
Correct |
68 ms |
468 KB |
Output is correct |
25 |
Correct |
65 ms |
448 KB |
Output is correct |
26 |
Correct |
78 ms |
472 KB |
Output is correct |
27 |
Correct |
79 ms |
456 KB |
Output is correct |
28 |
Correct |
74 ms |
468 KB |
Output is correct |
29 |
Correct |
75 ms |
452 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
74 ms |
468 KB |
Output is correct |
32 |
Correct |
77 ms |
468 KB |
Output is correct |
33 |
Correct |
76 ms |
468 KB |
Output is correct |
34 |
Correct |
83 ms |
468 KB |
Output is correct |
35 |
Correct |
73 ms |
468 KB |
Output is correct |
36 |
Correct |
72 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
448 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
448 KB |
Output is correct |
10 |
Correct |
7 ms |
468 KB |
Output is correct |
11 |
Correct |
8 ms |
468 KB |
Output is correct |
12 |
Correct |
7 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
468 KB |
Output is correct |
15 |
Correct |
6 ms |
468 KB |
Output is correct |
16 |
Correct |
7 ms |
448 KB |
Output is correct |
17 |
Correct |
3 ms |
468 KB |
Output is correct |
18 |
Correct |
5 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
7 ms |
476 KB |
Output is correct |
21 |
Correct |
32 ms |
468 KB |
Output is correct |
22 |
Correct |
46 ms |
468 KB |
Output is correct |
23 |
Correct |
20 ms |
468 KB |
Output is correct |
24 |
Correct |
68 ms |
468 KB |
Output is correct |
25 |
Correct |
65 ms |
448 KB |
Output is correct |
26 |
Correct |
78 ms |
472 KB |
Output is correct |
27 |
Correct |
79 ms |
456 KB |
Output is correct |
28 |
Correct |
74 ms |
468 KB |
Output is correct |
29 |
Correct |
75 ms |
452 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
74 ms |
468 KB |
Output is correct |
32 |
Correct |
77 ms |
468 KB |
Output is correct |
33 |
Correct |
76 ms |
468 KB |
Output is correct |
34 |
Correct |
83 ms |
468 KB |
Output is correct |
35 |
Correct |
73 ms |
468 KB |
Output is correct |
36 |
Correct |
72 ms |
468 KB |
Output is correct |
37 |
Correct |
301 ms |
468 KB |
Output is correct |
38 |
Correct |
287 ms |
468 KB |
Output is correct |
39 |
Correct |
484 ms |
468 KB |
Output is correct |
40 |
Correct |
528 ms |
468 KB |
Output is correct |
41 |
Correct |
530 ms |
464 KB |
Output is correct |
42 |
Correct |
473 ms |
468 KB |
Output is correct |
43 |
Correct |
441 ms |
592 KB |
Output is correct |
44 |
Correct |
464 ms |
584 KB |
Output is correct |
45 |
Correct |
468 ms |
588 KB |
Output is correct |
46 |
Correct |
520 ms |
476 KB |
Output is correct |
47 |
Correct |
448 ms |
472 KB |
Output is correct |
48 |
Correct |
467 ms |
468 KB |
Output is correct |
49 |
Correct |
459 ms |
468 KB |
Output is correct |
50 |
Correct |
458 ms |
468 KB |
Output is correct |
51 |
Correct |
0 ms |
340 KB |
Output is correct |
52 |
Correct |
525 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
448 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
448 KB |
Output is correct |
10 |
Correct |
7 ms |
468 KB |
Output is correct |
11 |
Correct |
8 ms |
468 KB |
Output is correct |
12 |
Correct |
7 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
468 KB |
Output is correct |
15 |
Correct |
6 ms |
468 KB |
Output is correct |
16 |
Correct |
7 ms |
448 KB |
Output is correct |
17 |
Correct |
3 ms |
468 KB |
Output is correct |
18 |
Correct |
5 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
7 ms |
476 KB |
Output is correct |
21 |
Correct |
32 ms |
468 KB |
Output is correct |
22 |
Correct |
46 ms |
468 KB |
Output is correct |
23 |
Correct |
20 ms |
468 KB |
Output is correct |
24 |
Correct |
68 ms |
468 KB |
Output is correct |
25 |
Correct |
65 ms |
448 KB |
Output is correct |
26 |
Correct |
78 ms |
472 KB |
Output is correct |
27 |
Correct |
79 ms |
456 KB |
Output is correct |
28 |
Correct |
74 ms |
468 KB |
Output is correct |
29 |
Correct |
75 ms |
452 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
74 ms |
468 KB |
Output is correct |
32 |
Correct |
77 ms |
468 KB |
Output is correct |
33 |
Correct |
76 ms |
468 KB |
Output is correct |
34 |
Correct |
83 ms |
468 KB |
Output is correct |
35 |
Correct |
73 ms |
468 KB |
Output is correct |
36 |
Correct |
72 ms |
468 KB |
Output is correct |
37 |
Correct |
301 ms |
468 KB |
Output is correct |
38 |
Correct |
287 ms |
468 KB |
Output is correct |
39 |
Correct |
484 ms |
468 KB |
Output is correct |
40 |
Correct |
528 ms |
468 KB |
Output is correct |
41 |
Correct |
530 ms |
464 KB |
Output is correct |
42 |
Correct |
473 ms |
468 KB |
Output is correct |
43 |
Correct |
441 ms |
592 KB |
Output is correct |
44 |
Correct |
464 ms |
584 KB |
Output is correct |
45 |
Correct |
468 ms |
588 KB |
Output is correct |
46 |
Correct |
520 ms |
476 KB |
Output is correct |
47 |
Correct |
448 ms |
472 KB |
Output is correct |
48 |
Correct |
467 ms |
468 KB |
Output is correct |
49 |
Correct |
459 ms |
468 KB |
Output is correct |
50 |
Correct |
458 ms |
468 KB |
Output is correct |
51 |
Correct |
0 ms |
340 KB |
Output is correct |
52 |
Correct |
525 ms |
588 KB |
Output is correct |
53 |
Correct |
666 ms |
588 KB |
Output is correct |
54 |
Correct |
891 ms |
600 KB |
Output is correct |
55 |
Correct |
894 ms |
716 KB |
Output is correct |
56 |
Correct |
698 ms |
588 KB |
Output is correct |
57 |
Correct |
902 ms |
708 KB |
Output is correct |
58 |
Correct |
922 ms |
588 KB |
Output is correct |
59 |
Correct |
894 ms |
600 KB |
Output is correct |
60 |
Correct |
1 ms |
340 KB |
Output is correct |
61 |
Correct |
904 ms |
600 KB |
Output is correct |
62 |
Correct |
756 ms |
708 KB |
Output is correct |
63 |
Correct |
774 ms |
724 KB |
Output is correct |
64 |
Correct |
725 ms |
844 KB |
Output is correct |
65 |
Correct |
742 ms |
468 KB |
Output is correct |
66 |
Correct |
704 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
448 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
448 KB |
Output is correct |
10 |
Correct |
7 ms |
468 KB |
Output is correct |
11 |
Correct |
8 ms |
468 KB |
Output is correct |
12 |
Correct |
7 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
468 KB |
Output is correct |
15 |
Correct |
6 ms |
468 KB |
Output is correct |
16 |
Correct |
7 ms |
448 KB |
Output is correct |
17 |
Correct |
3 ms |
468 KB |
Output is correct |
18 |
Correct |
5 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
7 ms |
476 KB |
Output is correct |
21 |
Correct |
32 ms |
468 KB |
Output is correct |
22 |
Correct |
46 ms |
468 KB |
Output is correct |
23 |
Correct |
20 ms |
468 KB |
Output is correct |
24 |
Correct |
68 ms |
468 KB |
Output is correct |
25 |
Correct |
65 ms |
448 KB |
Output is correct |
26 |
Correct |
78 ms |
472 KB |
Output is correct |
27 |
Correct |
79 ms |
456 KB |
Output is correct |
28 |
Correct |
74 ms |
468 KB |
Output is correct |
29 |
Correct |
75 ms |
452 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
74 ms |
468 KB |
Output is correct |
32 |
Correct |
77 ms |
468 KB |
Output is correct |
33 |
Correct |
76 ms |
468 KB |
Output is correct |
34 |
Correct |
83 ms |
468 KB |
Output is correct |
35 |
Correct |
73 ms |
468 KB |
Output is correct |
36 |
Correct |
72 ms |
468 KB |
Output is correct |
37 |
Correct |
301 ms |
468 KB |
Output is correct |
38 |
Correct |
287 ms |
468 KB |
Output is correct |
39 |
Correct |
484 ms |
468 KB |
Output is correct |
40 |
Correct |
528 ms |
468 KB |
Output is correct |
41 |
Correct |
530 ms |
464 KB |
Output is correct |
42 |
Correct |
473 ms |
468 KB |
Output is correct |
43 |
Correct |
441 ms |
592 KB |
Output is correct |
44 |
Correct |
464 ms |
584 KB |
Output is correct |
45 |
Correct |
468 ms |
588 KB |
Output is correct |
46 |
Correct |
520 ms |
476 KB |
Output is correct |
47 |
Correct |
448 ms |
472 KB |
Output is correct |
48 |
Correct |
467 ms |
468 KB |
Output is correct |
49 |
Correct |
459 ms |
468 KB |
Output is correct |
50 |
Correct |
458 ms |
468 KB |
Output is correct |
51 |
Correct |
0 ms |
340 KB |
Output is correct |
52 |
Correct |
525 ms |
588 KB |
Output is correct |
53 |
Correct |
666 ms |
588 KB |
Output is correct |
54 |
Correct |
891 ms |
600 KB |
Output is correct |
55 |
Correct |
894 ms |
716 KB |
Output is correct |
56 |
Correct |
698 ms |
588 KB |
Output is correct |
57 |
Correct |
902 ms |
708 KB |
Output is correct |
58 |
Correct |
922 ms |
588 KB |
Output is correct |
59 |
Correct |
894 ms |
600 KB |
Output is correct |
60 |
Correct |
1 ms |
340 KB |
Output is correct |
61 |
Correct |
904 ms |
600 KB |
Output is correct |
62 |
Correct |
756 ms |
708 KB |
Output is correct |
63 |
Correct |
774 ms |
724 KB |
Output is correct |
64 |
Correct |
725 ms |
844 KB |
Output is correct |
65 |
Correct |
742 ms |
468 KB |
Output is correct |
66 |
Correct |
704 ms |
468 KB |
Output is correct |
67 |
Execution timed out |
1061 ms |
448 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |