#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define int long long
#define itr iterator
typedef pair<ll,ll> pii;
const ll MAX=3e5+9;
const ll LIM=3e5;
const ll mod=1e9+7;
bitset<500*500+9> bs;
ll N,sum,arr[500*500+9],dp[500*500+9];
void TakeMod(ll &X,ll Y)
{
while(X<0)
X+=Y;
while(X>=Y)
X-=Y;
return ;
}
void add(ll X)
{
sum+=X;
for(int A=500*500;A>=X;A--)
{
dp[A]+=dp[A-X];
TakeMod(dp[A],mod);
}
return ;
}
void remove(ll X)
{
sum-=X;
for(int A=X;A<=500*500;A++)
{
dp[A]-=dp[A-X];
TakeMod(dp[A],mod);
}
return ;
}
signed main()
{
ios_base::sync_with_stdio(false);
dp[0]=1;
cin>>N;
for(int A=1;A<=N;A++)
{
cin>>arr[A];
add(arr[A]);
}
if(sum%2 or (!dp[sum/2]))
return cout<<0,0;
for(int A=1;A<=500*500;A++)
bs[A]=1;
for(int A=1;A<=N;A++)
{
remove(arr[A]);
for(int B=1;B<=500*500;B++)
if(B>sum or (sum+B)%2 or (!dp[(sum+B)/2]))
bs[B]=0;
add(arr[A]);
}
vector<int> vec;
for(int A=1;A<=sum;A++)
if(bs[A])
vec.pb(A);
cout<<vec.size()<<"\n";
for(auto A:vec)
cout<<A<<" ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
2296 KB |
Output is correct |
2 |
Correct |
20 ms |
2428 KB |
Output is correct |
3 |
Correct |
5 ms |
2428 KB |
Output is correct |
4 |
Correct |
11 ms |
2436 KB |
Output is correct |
5 |
Correct |
24 ms |
2488 KB |
Output is correct |
6 |
Correct |
18 ms |
2488 KB |
Output is correct |
7 |
Correct |
15 ms |
2488 KB |
Output is correct |
8 |
Correct |
24 ms |
2564 KB |
Output is correct |
9 |
Correct |
21 ms |
2564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
2296 KB |
Output is correct |
2 |
Correct |
20 ms |
2428 KB |
Output is correct |
3 |
Correct |
5 ms |
2428 KB |
Output is correct |
4 |
Correct |
11 ms |
2436 KB |
Output is correct |
5 |
Correct |
24 ms |
2488 KB |
Output is correct |
6 |
Correct |
18 ms |
2488 KB |
Output is correct |
7 |
Correct |
15 ms |
2488 KB |
Output is correct |
8 |
Correct |
24 ms |
2564 KB |
Output is correct |
9 |
Correct |
21 ms |
2564 KB |
Output is correct |
10 |
Correct |
53 ms |
2640 KB |
Output is correct |
11 |
Correct |
54 ms |
2640 KB |
Output is correct |
12 |
Correct |
52 ms |
2640 KB |
Output is correct |
13 |
Correct |
47 ms |
2640 KB |
Output is correct |
14 |
Correct |
50 ms |
2640 KB |
Output is correct |
15 |
Correct |
51 ms |
2640 KB |
Output is correct |
16 |
Correct |
54 ms |
2668 KB |
Output is correct |
17 |
Correct |
34 ms |
2668 KB |
Output is correct |
18 |
Correct |
44 ms |
2668 KB |
Output is correct |
19 |
Correct |
48 ms |
2668 KB |
Output is correct |
20 |
Correct |
54 ms |
2668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
2296 KB |
Output is correct |
2 |
Correct |
20 ms |
2428 KB |
Output is correct |
3 |
Correct |
5 ms |
2428 KB |
Output is correct |
4 |
Correct |
11 ms |
2436 KB |
Output is correct |
5 |
Correct |
24 ms |
2488 KB |
Output is correct |
6 |
Correct |
18 ms |
2488 KB |
Output is correct |
7 |
Correct |
15 ms |
2488 KB |
Output is correct |
8 |
Correct |
24 ms |
2564 KB |
Output is correct |
9 |
Correct |
21 ms |
2564 KB |
Output is correct |
10 |
Correct |
53 ms |
2640 KB |
Output is correct |
11 |
Correct |
54 ms |
2640 KB |
Output is correct |
12 |
Correct |
52 ms |
2640 KB |
Output is correct |
13 |
Correct |
47 ms |
2640 KB |
Output is correct |
14 |
Correct |
50 ms |
2640 KB |
Output is correct |
15 |
Correct |
51 ms |
2640 KB |
Output is correct |
16 |
Correct |
54 ms |
2668 KB |
Output is correct |
17 |
Correct |
34 ms |
2668 KB |
Output is correct |
18 |
Correct |
44 ms |
2668 KB |
Output is correct |
19 |
Correct |
48 ms |
2668 KB |
Output is correct |
20 |
Correct |
54 ms |
2668 KB |
Output is correct |
21 |
Correct |
109 ms |
2668 KB |
Output is correct |
22 |
Correct |
125 ms |
2668 KB |
Output is correct |
23 |
Correct |
85 ms |
2668 KB |
Output is correct |
24 |
Correct |
162 ms |
2728 KB |
Output is correct |
25 |
Correct |
181 ms |
2728 KB |
Output is correct |
26 |
Correct |
173 ms |
2728 KB |
Output is correct |
27 |
Correct |
169 ms |
2728 KB |
Output is correct |
28 |
Correct |
171 ms |
2728 KB |
Output is correct |
29 |
Correct |
179 ms |
2728 KB |
Output is correct |
30 |
Correct |
171 ms |
2728 KB |
Output is correct |
31 |
Correct |
177 ms |
2732 KB |
Output is correct |
32 |
Correct |
173 ms |
2732 KB |
Output is correct |
33 |
Correct |
177 ms |
2732 KB |
Output is correct |
34 |
Correct |
168 ms |
2732 KB |
Output is correct |
35 |
Correct |
213 ms |
2732 KB |
Output is correct |
36 |
Correct |
170 ms |
2732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
2296 KB |
Output is correct |
2 |
Correct |
20 ms |
2428 KB |
Output is correct |
3 |
Correct |
5 ms |
2428 KB |
Output is correct |
4 |
Correct |
11 ms |
2436 KB |
Output is correct |
5 |
Correct |
24 ms |
2488 KB |
Output is correct |
6 |
Correct |
18 ms |
2488 KB |
Output is correct |
7 |
Correct |
15 ms |
2488 KB |
Output is correct |
8 |
Correct |
24 ms |
2564 KB |
Output is correct |
9 |
Correct |
21 ms |
2564 KB |
Output is correct |
10 |
Correct |
53 ms |
2640 KB |
Output is correct |
11 |
Correct |
54 ms |
2640 KB |
Output is correct |
12 |
Correct |
52 ms |
2640 KB |
Output is correct |
13 |
Correct |
47 ms |
2640 KB |
Output is correct |
14 |
Correct |
50 ms |
2640 KB |
Output is correct |
15 |
Correct |
51 ms |
2640 KB |
Output is correct |
16 |
Correct |
54 ms |
2668 KB |
Output is correct |
17 |
Correct |
34 ms |
2668 KB |
Output is correct |
18 |
Correct |
44 ms |
2668 KB |
Output is correct |
19 |
Correct |
48 ms |
2668 KB |
Output is correct |
20 |
Correct |
54 ms |
2668 KB |
Output is correct |
21 |
Correct |
109 ms |
2668 KB |
Output is correct |
22 |
Correct |
125 ms |
2668 KB |
Output is correct |
23 |
Correct |
85 ms |
2668 KB |
Output is correct |
24 |
Correct |
162 ms |
2728 KB |
Output is correct |
25 |
Correct |
181 ms |
2728 KB |
Output is correct |
26 |
Correct |
173 ms |
2728 KB |
Output is correct |
27 |
Correct |
169 ms |
2728 KB |
Output is correct |
28 |
Correct |
171 ms |
2728 KB |
Output is correct |
29 |
Correct |
179 ms |
2728 KB |
Output is correct |
30 |
Correct |
171 ms |
2728 KB |
Output is correct |
31 |
Correct |
177 ms |
2732 KB |
Output is correct |
32 |
Correct |
173 ms |
2732 KB |
Output is correct |
33 |
Correct |
177 ms |
2732 KB |
Output is correct |
34 |
Correct |
168 ms |
2732 KB |
Output is correct |
35 |
Correct |
213 ms |
2732 KB |
Output is correct |
36 |
Correct |
170 ms |
2732 KB |
Output is correct |
37 |
Correct |
367 ms |
3004 KB |
Output is correct |
38 |
Correct |
382 ms |
3004 KB |
Output is correct |
39 |
Correct |
454 ms |
3004 KB |
Output is correct |
40 |
Correct |
546 ms |
3004 KB |
Output is correct |
41 |
Correct |
445 ms |
3004 KB |
Output is correct |
42 |
Correct |
490 ms |
3004 KB |
Output is correct |
43 |
Correct |
547 ms |
3260 KB |
Output is correct |
44 |
Correct |
613 ms |
3260 KB |
Output is correct |
45 |
Correct |
604 ms |
3260 KB |
Output is correct |
46 |
Correct |
495 ms |
3260 KB |
Output is correct |
47 |
Correct |
513 ms |
3260 KB |
Output is correct |
48 |
Correct |
575 ms |
3260 KB |
Output is correct |
49 |
Correct |
498 ms |
3260 KB |
Output is correct |
50 |
Correct |
508 ms |
3260 KB |
Output is correct |
51 |
Correct |
108 ms |
3260 KB |
Output is correct |
52 |
Correct |
647 ms |
3332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
2296 KB |
Output is correct |
2 |
Correct |
20 ms |
2428 KB |
Output is correct |
3 |
Correct |
5 ms |
2428 KB |
Output is correct |
4 |
Correct |
11 ms |
2436 KB |
Output is correct |
5 |
Correct |
24 ms |
2488 KB |
Output is correct |
6 |
Correct |
18 ms |
2488 KB |
Output is correct |
7 |
Correct |
15 ms |
2488 KB |
Output is correct |
8 |
Correct |
24 ms |
2564 KB |
Output is correct |
9 |
Correct |
21 ms |
2564 KB |
Output is correct |
10 |
Correct |
53 ms |
2640 KB |
Output is correct |
11 |
Correct |
54 ms |
2640 KB |
Output is correct |
12 |
Correct |
52 ms |
2640 KB |
Output is correct |
13 |
Correct |
47 ms |
2640 KB |
Output is correct |
14 |
Correct |
50 ms |
2640 KB |
Output is correct |
15 |
Correct |
51 ms |
2640 KB |
Output is correct |
16 |
Correct |
54 ms |
2668 KB |
Output is correct |
17 |
Correct |
34 ms |
2668 KB |
Output is correct |
18 |
Correct |
44 ms |
2668 KB |
Output is correct |
19 |
Correct |
48 ms |
2668 KB |
Output is correct |
20 |
Correct |
54 ms |
2668 KB |
Output is correct |
21 |
Correct |
109 ms |
2668 KB |
Output is correct |
22 |
Correct |
125 ms |
2668 KB |
Output is correct |
23 |
Correct |
85 ms |
2668 KB |
Output is correct |
24 |
Correct |
162 ms |
2728 KB |
Output is correct |
25 |
Correct |
181 ms |
2728 KB |
Output is correct |
26 |
Correct |
173 ms |
2728 KB |
Output is correct |
27 |
Correct |
169 ms |
2728 KB |
Output is correct |
28 |
Correct |
171 ms |
2728 KB |
Output is correct |
29 |
Correct |
179 ms |
2728 KB |
Output is correct |
30 |
Correct |
171 ms |
2728 KB |
Output is correct |
31 |
Correct |
177 ms |
2732 KB |
Output is correct |
32 |
Correct |
173 ms |
2732 KB |
Output is correct |
33 |
Correct |
177 ms |
2732 KB |
Output is correct |
34 |
Correct |
168 ms |
2732 KB |
Output is correct |
35 |
Correct |
213 ms |
2732 KB |
Output is correct |
36 |
Correct |
170 ms |
2732 KB |
Output is correct |
37 |
Correct |
367 ms |
3004 KB |
Output is correct |
38 |
Correct |
382 ms |
3004 KB |
Output is correct |
39 |
Correct |
454 ms |
3004 KB |
Output is correct |
40 |
Correct |
546 ms |
3004 KB |
Output is correct |
41 |
Correct |
445 ms |
3004 KB |
Output is correct |
42 |
Correct |
490 ms |
3004 KB |
Output is correct |
43 |
Correct |
547 ms |
3260 KB |
Output is correct |
44 |
Correct |
613 ms |
3260 KB |
Output is correct |
45 |
Correct |
604 ms |
3260 KB |
Output is correct |
46 |
Correct |
495 ms |
3260 KB |
Output is correct |
47 |
Correct |
513 ms |
3260 KB |
Output is correct |
48 |
Correct |
575 ms |
3260 KB |
Output is correct |
49 |
Correct |
498 ms |
3260 KB |
Output is correct |
50 |
Correct |
508 ms |
3260 KB |
Output is correct |
51 |
Correct |
108 ms |
3260 KB |
Output is correct |
52 |
Correct |
647 ms |
3332 KB |
Output is correct |
53 |
Correct |
644 ms |
3332 KB |
Output is correct |
54 |
Correct |
800 ms |
3388 KB |
Output is correct |
55 |
Execution timed out |
1012 ms |
3636 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
2296 KB |
Output is correct |
2 |
Correct |
20 ms |
2428 KB |
Output is correct |
3 |
Correct |
5 ms |
2428 KB |
Output is correct |
4 |
Correct |
11 ms |
2436 KB |
Output is correct |
5 |
Correct |
24 ms |
2488 KB |
Output is correct |
6 |
Correct |
18 ms |
2488 KB |
Output is correct |
7 |
Correct |
15 ms |
2488 KB |
Output is correct |
8 |
Correct |
24 ms |
2564 KB |
Output is correct |
9 |
Correct |
21 ms |
2564 KB |
Output is correct |
10 |
Correct |
53 ms |
2640 KB |
Output is correct |
11 |
Correct |
54 ms |
2640 KB |
Output is correct |
12 |
Correct |
52 ms |
2640 KB |
Output is correct |
13 |
Correct |
47 ms |
2640 KB |
Output is correct |
14 |
Correct |
50 ms |
2640 KB |
Output is correct |
15 |
Correct |
51 ms |
2640 KB |
Output is correct |
16 |
Correct |
54 ms |
2668 KB |
Output is correct |
17 |
Correct |
34 ms |
2668 KB |
Output is correct |
18 |
Correct |
44 ms |
2668 KB |
Output is correct |
19 |
Correct |
48 ms |
2668 KB |
Output is correct |
20 |
Correct |
54 ms |
2668 KB |
Output is correct |
21 |
Correct |
109 ms |
2668 KB |
Output is correct |
22 |
Correct |
125 ms |
2668 KB |
Output is correct |
23 |
Correct |
85 ms |
2668 KB |
Output is correct |
24 |
Correct |
162 ms |
2728 KB |
Output is correct |
25 |
Correct |
181 ms |
2728 KB |
Output is correct |
26 |
Correct |
173 ms |
2728 KB |
Output is correct |
27 |
Correct |
169 ms |
2728 KB |
Output is correct |
28 |
Correct |
171 ms |
2728 KB |
Output is correct |
29 |
Correct |
179 ms |
2728 KB |
Output is correct |
30 |
Correct |
171 ms |
2728 KB |
Output is correct |
31 |
Correct |
177 ms |
2732 KB |
Output is correct |
32 |
Correct |
173 ms |
2732 KB |
Output is correct |
33 |
Correct |
177 ms |
2732 KB |
Output is correct |
34 |
Correct |
168 ms |
2732 KB |
Output is correct |
35 |
Correct |
213 ms |
2732 KB |
Output is correct |
36 |
Correct |
170 ms |
2732 KB |
Output is correct |
37 |
Correct |
367 ms |
3004 KB |
Output is correct |
38 |
Correct |
382 ms |
3004 KB |
Output is correct |
39 |
Correct |
454 ms |
3004 KB |
Output is correct |
40 |
Correct |
546 ms |
3004 KB |
Output is correct |
41 |
Correct |
445 ms |
3004 KB |
Output is correct |
42 |
Correct |
490 ms |
3004 KB |
Output is correct |
43 |
Correct |
547 ms |
3260 KB |
Output is correct |
44 |
Correct |
613 ms |
3260 KB |
Output is correct |
45 |
Correct |
604 ms |
3260 KB |
Output is correct |
46 |
Correct |
495 ms |
3260 KB |
Output is correct |
47 |
Correct |
513 ms |
3260 KB |
Output is correct |
48 |
Correct |
575 ms |
3260 KB |
Output is correct |
49 |
Correct |
498 ms |
3260 KB |
Output is correct |
50 |
Correct |
508 ms |
3260 KB |
Output is correct |
51 |
Correct |
108 ms |
3260 KB |
Output is correct |
52 |
Correct |
647 ms |
3332 KB |
Output is correct |
53 |
Correct |
644 ms |
3332 KB |
Output is correct |
54 |
Correct |
800 ms |
3388 KB |
Output is correct |
55 |
Execution timed out |
1012 ms |
3636 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |