#include <bits/stdc++.h>
using namespace std;
const int maxn=501;
const int maxc=501;
const int maxw=maxc*maxn;
bitset<maxn*maxc>available[maxn];
bitset<maxn*maxc>used[maxn];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
vector<int>a(n);
int sum=0;
for(int i=0;i<n;i++) {
cin>>a[i];
sum+=a[i];
}
for(int i=0;i<=n;i++){
if(i>0) {
available[i]=available[i-1];
available[i]|=available[i]<<a[i-1];
}
else available[i][0]=true;
}
for(int i=0;i<=n;i++){
for(int j=i+1;j<n;j++){
available[i]|=available[i]<<a[j];
}
}
if(sum&1){
cout<<0;
return 0;
}
if(!available[n][sum>>1]){
cout<<0;
return 0;
}
for(int i=0;i<n;i++){
if(((sum-a[i]) & 1) != ((sum-a[0])&1)){
cout<<0;
return 0;
}
}
vector<int>ans;
for(int x=(sum-a[0])&1;x<=maxw;x+=2){
bool ok=true;
for(int i=0;i<n;i++){
int nsum=sum-a[i]+x;
if(!available[i][nsum>>1]){
ok=false;
break;
}
}
if(ok){
ans.push_back(x);
}
}
cout<<ans.size()<<endl;
for(auto x:ans)cout<<x<<" ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
632 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
17 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
632 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
17 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
10 ms |
1400 KB |
Output is correct |
11 |
Correct |
10 ms |
1400 KB |
Output is correct |
12 |
Correct |
10 ms |
1400 KB |
Output is correct |
13 |
Correct |
8 ms |
1276 KB |
Output is correct |
14 |
Correct |
9 ms |
1272 KB |
Output is correct |
15 |
Correct |
9 ms |
1272 KB |
Output is correct |
16 |
Correct |
9 ms |
1400 KB |
Output is correct |
17 |
Correct |
5 ms |
1016 KB |
Output is correct |
18 |
Correct |
7 ms |
1144 KB |
Output is correct |
19 |
Correct |
8 ms |
1272 KB |
Output is correct |
20 |
Correct |
10 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
632 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
17 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
10 ms |
1400 KB |
Output is correct |
11 |
Correct |
10 ms |
1400 KB |
Output is correct |
12 |
Correct |
10 ms |
1400 KB |
Output is correct |
13 |
Correct |
8 ms |
1276 KB |
Output is correct |
14 |
Correct |
9 ms |
1272 KB |
Output is correct |
15 |
Correct |
9 ms |
1272 KB |
Output is correct |
16 |
Correct |
9 ms |
1400 KB |
Output is correct |
17 |
Correct |
5 ms |
1016 KB |
Output is correct |
18 |
Correct |
7 ms |
1144 KB |
Output is correct |
19 |
Correct |
8 ms |
1272 KB |
Output is correct |
20 |
Correct |
10 ms |
1400 KB |
Output is correct |
21 |
Correct |
33 ms |
2424 KB |
Output is correct |
22 |
Correct |
42 ms |
2808 KB |
Output is correct |
23 |
Correct |
21 ms |
2044 KB |
Output is correct |
24 |
Correct |
66 ms |
3324 KB |
Output is correct |
25 |
Correct |
66 ms |
3448 KB |
Output is correct |
26 |
Correct |
74 ms |
3704 KB |
Output is correct |
27 |
Correct |
73 ms |
3576 KB |
Output is correct |
28 |
Correct |
74 ms |
3576 KB |
Output is correct |
29 |
Correct |
73 ms |
3544 KB |
Output is correct |
30 |
Correct |
73 ms |
3540 KB |
Output is correct |
31 |
Correct |
74 ms |
3580 KB |
Output is correct |
32 |
Correct |
74 ms |
3576 KB |
Output is correct |
33 |
Correct |
73 ms |
3544 KB |
Output is correct |
34 |
Correct |
73 ms |
3576 KB |
Output is correct |
35 |
Correct |
73 ms |
3448 KB |
Output is correct |
36 |
Correct |
74 ms |
3576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
632 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
17 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
10 ms |
1400 KB |
Output is correct |
11 |
Correct |
10 ms |
1400 KB |
Output is correct |
12 |
Correct |
10 ms |
1400 KB |
Output is correct |
13 |
Correct |
8 ms |
1276 KB |
Output is correct |
14 |
Correct |
9 ms |
1272 KB |
Output is correct |
15 |
Correct |
9 ms |
1272 KB |
Output is correct |
16 |
Correct |
9 ms |
1400 KB |
Output is correct |
17 |
Correct |
5 ms |
1016 KB |
Output is correct |
18 |
Correct |
7 ms |
1144 KB |
Output is correct |
19 |
Correct |
8 ms |
1272 KB |
Output is correct |
20 |
Correct |
10 ms |
1400 KB |
Output is correct |
21 |
Correct |
33 ms |
2424 KB |
Output is correct |
22 |
Correct |
42 ms |
2808 KB |
Output is correct |
23 |
Correct |
21 ms |
2044 KB |
Output is correct |
24 |
Correct |
66 ms |
3324 KB |
Output is correct |
25 |
Correct |
66 ms |
3448 KB |
Output is correct |
26 |
Correct |
74 ms |
3704 KB |
Output is correct |
27 |
Correct |
73 ms |
3576 KB |
Output is correct |
28 |
Correct |
74 ms |
3576 KB |
Output is correct |
29 |
Correct |
73 ms |
3544 KB |
Output is correct |
30 |
Correct |
73 ms |
3540 KB |
Output is correct |
31 |
Correct |
74 ms |
3580 KB |
Output is correct |
32 |
Correct |
74 ms |
3576 KB |
Output is correct |
33 |
Correct |
73 ms |
3544 KB |
Output is correct |
34 |
Correct |
73 ms |
3576 KB |
Output is correct |
35 |
Correct |
73 ms |
3448 KB |
Output is correct |
36 |
Correct |
74 ms |
3576 KB |
Output is correct |
37 |
Correct |
281 ms |
6760 KB |
Output is correct |
38 |
Correct |
282 ms |
6740 KB |
Output is correct |
39 |
Correct |
421 ms |
8108 KB |
Output is correct |
40 |
Correct |
510 ms |
8892 KB |
Output is correct |
41 |
Correct |
502 ms |
8696 KB |
Output is correct |
42 |
Correct |
438 ms |
8312 KB |
Output is correct |
43 |
Correct |
432 ms |
8312 KB |
Output is correct |
44 |
Correct |
438 ms |
8440 KB |
Output is correct |
45 |
Correct |
446 ms |
8568 KB |
Output is correct |
46 |
Correct |
493 ms |
8696 KB |
Output is correct |
47 |
Correct |
440 ms |
8412 KB |
Output is correct |
48 |
Correct |
441 ms |
8444 KB |
Output is correct |
49 |
Correct |
434 ms |
8184 KB |
Output is correct |
50 |
Correct |
440 ms |
8440 KB |
Output is correct |
51 |
Correct |
428 ms |
8184 KB |
Output is correct |
52 |
Correct |
520 ms |
9208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
632 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
17 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
10 ms |
1400 KB |
Output is correct |
11 |
Correct |
10 ms |
1400 KB |
Output is correct |
12 |
Correct |
10 ms |
1400 KB |
Output is correct |
13 |
Correct |
8 ms |
1276 KB |
Output is correct |
14 |
Correct |
9 ms |
1272 KB |
Output is correct |
15 |
Correct |
9 ms |
1272 KB |
Output is correct |
16 |
Correct |
9 ms |
1400 KB |
Output is correct |
17 |
Correct |
5 ms |
1016 KB |
Output is correct |
18 |
Correct |
7 ms |
1144 KB |
Output is correct |
19 |
Correct |
8 ms |
1272 KB |
Output is correct |
20 |
Correct |
10 ms |
1400 KB |
Output is correct |
21 |
Correct |
33 ms |
2424 KB |
Output is correct |
22 |
Correct |
42 ms |
2808 KB |
Output is correct |
23 |
Correct |
21 ms |
2044 KB |
Output is correct |
24 |
Correct |
66 ms |
3324 KB |
Output is correct |
25 |
Correct |
66 ms |
3448 KB |
Output is correct |
26 |
Correct |
74 ms |
3704 KB |
Output is correct |
27 |
Correct |
73 ms |
3576 KB |
Output is correct |
28 |
Correct |
74 ms |
3576 KB |
Output is correct |
29 |
Correct |
73 ms |
3544 KB |
Output is correct |
30 |
Correct |
73 ms |
3540 KB |
Output is correct |
31 |
Correct |
74 ms |
3580 KB |
Output is correct |
32 |
Correct |
74 ms |
3576 KB |
Output is correct |
33 |
Correct |
73 ms |
3544 KB |
Output is correct |
34 |
Correct |
73 ms |
3576 KB |
Output is correct |
35 |
Correct |
73 ms |
3448 KB |
Output is correct |
36 |
Correct |
74 ms |
3576 KB |
Output is correct |
37 |
Correct |
281 ms |
6760 KB |
Output is correct |
38 |
Correct |
282 ms |
6740 KB |
Output is correct |
39 |
Correct |
421 ms |
8108 KB |
Output is correct |
40 |
Correct |
510 ms |
8892 KB |
Output is correct |
41 |
Correct |
502 ms |
8696 KB |
Output is correct |
42 |
Correct |
438 ms |
8312 KB |
Output is correct |
43 |
Correct |
432 ms |
8312 KB |
Output is correct |
44 |
Correct |
438 ms |
8440 KB |
Output is correct |
45 |
Correct |
446 ms |
8568 KB |
Output is correct |
46 |
Correct |
493 ms |
8696 KB |
Output is correct |
47 |
Correct |
440 ms |
8412 KB |
Output is correct |
48 |
Correct |
441 ms |
8444 KB |
Output is correct |
49 |
Correct |
434 ms |
8184 KB |
Output is correct |
50 |
Correct |
440 ms |
8440 KB |
Output is correct |
51 |
Correct |
428 ms |
8184 KB |
Output is correct |
52 |
Correct |
520 ms |
9208 KB |
Output is correct |
53 |
Correct |
649 ms |
9948 KB |
Output is correct |
54 |
Correct |
857 ms |
11600 KB |
Output is correct |
55 |
Correct |
875 ms |
11868 KB |
Output is correct |
56 |
Correct |
660 ms |
10232 KB |
Output is correct |
57 |
Correct |
948 ms |
11896 KB |
Output is correct |
58 |
Correct |
859 ms |
11772 KB |
Output is correct |
59 |
Correct |
868 ms |
11768 KB |
Output is correct |
60 |
Correct |
831 ms |
11256 KB |
Output is correct |
61 |
Correct |
876 ms |
11812 KB |
Output is correct |
62 |
Correct |
738 ms |
10848 KB |
Output is correct |
63 |
Correct |
735 ms |
11000 KB |
Output is correct |
64 |
Correct |
708 ms |
10872 KB |
Output is correct |
65 |
Correct |
683 ms |
10212 KB |
Output is correct |
66 |
Correct |
673 ms |
10104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
632 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
17 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
10 ms |
1400 KB |
Output is correct |
11 |
Correct |
10 ms |
1400 KB |
Output is correct |
12 |
Correct |
10 ms |
1400 KB |
Output is correct |
13 |
Correct |
8 ms |
1276 KB |
Output is correct |
14 |
Correct |
9 ms |
1272 KB |
Output is correct |
15 |
Correct |
9 ms |
1272 KB |
Output is correct |
16 |
Correct |
9 ms |
1400 KB |
Output is correct |
17 |
Correct |
5 ms |
1016 KB |
Output is correct |
18 |
Correct |
7 ms |
1144 KB |
Output is correct |
19 |
Correct |
8 ms |
1272 KB |
Output is correct |
20 |
Correct |
10 ms |
1400 KB |
Output is correct |
21 |
Correct |
33 ms |
2424 KB |
Output is correct |
22 |
Correct |
42 ms |
2808 KB |
Output is correct |
23 |
Correct |
21 ms |
2044 KB |
Output is correct |
24 |
Correct |
66 ms |
3324 KB |
Output is correct |
25 |
Correct |
66 ms |
3448 KB |
Output is correct |
26 |
Correct |
74 ms |
3704 KB |
Output is correct |
27 |
Correct |
73 ms |
3576 KB |
Output is correct |
28 |
Correct |
74 ms |
3576 KB |
Output is correct |
29 |
Correct |
73 ms |
3544 KB |
Output is correct |
30 |
Correct |
73 ms |
3540 KB |
Output is correct |
31 |
Correct |
74 ms |
3580 KB |
Output is correct |
32 |
Correct |
74 ms |
3576 KB |
Output is correct |
33 |
Correct |
73 ms |
3544 KB |
Output is correct |
34 |
Correct |
73 ms |
3576 KB |
Output is correct |
35 |
Correct |
73 ms |
3448 KB |
Output is correct |
36 |
Correct |
74 ms |
3576 KB |
Output is correct |
37 |
Correct |
281 ms |
6760 KB |
Output is correct |
38 |
Correct |
282 ms |
6740 KB |
Output is correct |
39 |
Correct |
421 ms |
8108 KB |
Output is correct |
40 |
Correct |
510 ms |
8892 KB |
Output is correct |
41 |
Correct |
502 ms |
8696 KB |
Output is correct |
42 |
Correct |
438 ms |
8312 KB |
Output is correct |
43 |
Correct |
432 ms |
8312 KB |
Output is correct |
44 |
Correct |
438 ms |
8440 KB |
Output is correct |
45 |
Correct |
446 ms |
8568 KB |
Output is correct |
46 |
Correct |
493 ms |
8696 KB |
Output is correct |
47 |
Correct |
440 ms |
8412 KB |
Output is correct |
48 |
Correct |
441 ms |
8444 KB |
Output is correct |
49 |
Correct |
434 ms |
8184 KB |
Output is correct |
50 |
Correct |
440 ms |
8440 KB |
Output is correct |
51 |
Correct |
428 ms |
8184 KB |
Output is correct |
52 |
Correct |
520 ms |
9208 KB |
Output is correct |
53 |
Correct |
649 ms |
9948 KB |
Output is correct |
54 |
Correct |
857 ms |
11600 KB |
Output is correct |
55 |
Correct |
875 ms |
11868 KB |
Output is correct |
56 |
Correct |
660 ms |
10232 KB |
Output is correct |
57 |
Correct |
948 ms |
11896 KB |
Output is correct |
58 |
Correct |
859 ms |
11772 KB |
Output is correct |
59 |
Correct |
868 ms |
11768 KB |
Output is correct |
60 |
Correct |
831 ms |
11256 KB |
Output is correct |
61 |
Correct |
876 ms |
11812 KB |
Output is correct |
62 |
Correct |
738 ms |
10848 KB |
Output is correct |
63 |
Correct |
735 ms |
11000 KB |
Output is correct |
64 |
Correct |
708 ms |
10872 KB |
Output is correct |
65 |
Correct |
683 ms |
10212 KB |
Output is correct |
66 |
Correct |
673 ms |
10104 KB |
Output is correct |
67 |
Execution timed out |
1075 ms |
12664 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |