#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<LIM> bs;
ll N,sum,arr[MAX],dp[MAX];
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=LIM;A>=X;A--)
{
dp[A]+=dp[A-X];
TakeMod(dp[A],mod);
}
return ;
}
void remove(ll X)
{
sum-=X;
for(int A=X;A<LIM;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<=LIM;A++)
bs[A]=1;
for(int A=1;A<=N;A++)
{
remove(arr[A]);
for(int B=1;B<=LIM;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 |
14 ms |
2680 KB |
Output is correct |
2 |
Correct |
17 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2848 KB |
Output is correct |
4 |
Correct |
14 ms |
3032 KB |
Output is correct |
5 |
Correct |
30 ms |
3032 KB |
Output is correct |
6 |
Correct |
21 ms |
3032 KB |
Output is correct |
7 |
Correct |
17 ms |
3032 KB |
Output is correct |
8 |
Correct |
28 ms |
3032 KB |
Output is correct |
9 |
Correct |
25 ms |
3080 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2680 KB |
Output is correct |
2 |
Correct |
17 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2848 KB |
Output is correct |
4 |
Correct |
14 ms |
3032 KB |
Output is correct |
5 |
Correct |
30 ms |
3032 KB |
Output is correct |
6 |
Correct |
21 ms |
3032 KB |
Output is correct |
7 |
Correct |
17 ms |
3032 KB |
Output is correct |
8 |
Correct |
28 ms |
3032 KB |
Output is correct |
9 |
Correct |
25 ms |
3080 KB |
Output is correct |
10 |
Correct |
62 ms |
3084 KB |
Output is correct |
11 |
Correct |
68 ms |
3084 KB |
Output is correct |
12 |
Correct |
64 ms |
3084 KB |
Output is correct |
13 |
Correct |
55 ms |
3084 KB |
Output is correct |
14 |
Correct |
59 ms |
3084 KB |
Output is correct |
15 |
Correct |
68 ms |
3084 KB |
Output is correct |
16 |
Correct |
70 ms |
3084 KB |
Output is correct |
17 |
Correct |
40 ms |
3084 KB |
Output is correct |
18 |
Correct |
53 ms |
3116 KB |
Output is correct |
19 |
Correct |
55 ms |
3116 KB |
Output is correct |
20 |
Correct |
66 ms |
3116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2680 KB |
Output is correct |
2 |
Correct |
17 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2848 KB |
Output is correct |
4 |
Correct |
14 ms |
3032 KB |
Output is correct |
5 |
Correct |
30 ms |
3032 KB |
Output is correct |
6 |
Correct |
21 ms |
3032 KB |
Output is correct |
7 |
Correct |
17 ms |
3032 KB |
Output is correct |
8 |
Correct |
28 ms |
3032 KB |
Output is correct |
9 |
Correct |
25 ms |
3080 KB |
Output is correct |
10 |
Correct |
62 ms |
3084 KB |
Output is correct |
11 |
Correct |
68 ms |
3084 KB |
Output is correct |
12 |
Correct |
64 ms |
3084 KB |
Output is correct |
13 |
Correct |
55 ms |
3084 KB |
Output is correct |
14 |
Correct |
59 ms |
3084 KB |
Output is correct |
15 |
Correct |
68 ms |
3084 KB |
Output is correct |
16 |
Correct |
70 ms |
3084 KB |
Output is correct |
17 |
Correct |
40 ms |
3084 KB |
Output is correct |
18 |
Correct |
53 ms |
3116 KB |
Output is correct |
19 |
Correct |
55 ms |
3116 KB |
Output is correct |
20 |
Correct |
66 ms |
3116 KB |
Output is correct |
21 |
Correct |
137 ms |
3160 KB |
Output is correct |
22 |
Correct |
179 ms |
3160 KB |
Output is correct |
23 |
Correct |
110 ms |
3216 KB |
Output is correct |
24 |
Correct |
197 ms |
3216 KB |
Output is correct |
25 |
Correct |
242 ms |
3312 KB |
Output is correct |
26 |
Correct |
217 ms |
3312 KB |
Output is correct |
27 |
Correct |
209 ms |
3312 KB |
Output is correct |
28 |
Correct |
209 ms |
3324 KB |
Output is correct |
29 |
Correct |
204 ms |
3344 KB |
Output is correct |
30 |
Correct |
208 ms |
3344 KB |
Output is correct |
31 |
Correct |
241 ms |
3356 KB |
Output is correct |
32 |
Correct |
215 ms |
3360 KB |
Output is correct |
33 |
Correct |
205 ms |
3364 KB |
Output is correct |
34 |
Correct |
226 ms |
3368 KB |
Output is correct |
35 |
Correct |
226 ms |
3372 KB |
Output is correct |
36 |
Correct |
203 ms |
3536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2680 KB |
Output is correct |
2 |
Correct |
17 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2848 KB |
Output is correct |
4 |
Correct |
14 ms |
3032 KB |
Output is correct |
5 |
Correct |
30 ms |
3032 KB |
Output is correct |
6 |
Correct |
21 ms |
3032 KB |
Output is correct |
7 |
Correct |
17 ms |
3032 KB |
Output is correct |
8 |
Correct |
28 ms |
3032 KB |
Output is correct |
9 |
Correct |
25 ms |
3080 KB |
Output is correct |
10 |
Correct |
62 ms |
3084 KB |
Output is correct |
11 |
Correct |
68 ms |
3084 KB |
Output is correct |
12 |
Correct |
64 ms |
3084 KB |
Output is correct |
13 |
Correct |
55 ms |
3084 KB |
Output is correct |
14 |
Correct |
59 ms |
3084 KB |
Output is correct |
15 |
Correct |
68 ms |
3084 KB |
Output is correct |
16 |
Correct |
70 ms |
3084 KB |
Output is correct |
17 |
Correct |
40 ms |
3084 KB |
Output is correct |
18 |
Correct |
53 ms |
3116 KB |
Output is correct |
19 |
Correct |
55 ms |
3116 KB |
Output is correct |
20 |
Correct |
66 ms |
3116 KB |
Output is correct |
21 |
Correct |
137 ms |
3160 KB |
Output is correct |
22 |
Correct |
179 ms |
3160 KB |
Output is correct |
23 |
Correct |
110 ms |
3216 KB |
Output is correct |
24 |
Correct |
197 ms |
3216 KB |
Output is correct |
25 |
Correct |
242 ms |
3312 KB |
Output is correct |
26 |
Correct |
217 ms |
3312 KB |
Output is correct |
27 |
Correct |
209 ms |
3312 KB |
Output is correct |
28 |
Correct |
209 ms |
3324 KB |
Output is correct |
29 |
Correct |
204 ms |
3344 KB |
Output is correct |
30 |
Correct |
208 ms |
3344 KB |
Output is correct |
31 |
Correct |
241 ms |
3356 KB |
Output is correct |
32 |
Correct |
215 ms |
3360 KB |
Output is correct |
33 |
Correct |
205 ms |
3364 KB |
Output is correct |
34 |
Correct |
226 ms |
3368 KB |
Output is correct |
35 |
Correct |
226 ms |
3372 KB |
Output is correct |
36 |
Correct |
203 ms |
3536 KB |
Output is correct |
37 |
Correct |
483 ms |
3600 KB |
Output is correct |
38 |
Correct |
444 ms |
3672 KB |
Output is correct |
39 |
Correct |
516 ms |
3672 KB |
Output is correct |
40 |
Correct |
688 ms |
3744 KB |
Output is correct |
41 |
Correct |
545 ms |
3744 KB |
Output is correct |
42 |
Correct |
638 ms |
3816 KB |
Output is correct |
43 |
Correct |
654 ms |
3948 KB |
Output is correct |
44 |
Correct |
695 ms |
3948 KB |
Output is correct |
45 |
Correct |
645 ms |
3948 KB |
Output is correct |
46 |
Correct |
620 ms |
3948 KB |
Output is correct |
47 |
Correct |
602 ms |
3948 KB |
Output is correct |
48 |
Correct |
634 ms |
3968 KB |
Output is correct |
49 |
Correct |
624 ms |
3968 KB |
Output is correct |
50 |
Correct |
649 ms |
3968 KB |
Output is correct |
51 |
Correct |
122 ms |
3968 KB |
Output is correct |
52 |
Correct |
748 ms |
3968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2680 KB |
Output is correct |
2 |
Correct |
17 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2848 KB |
Output is correct |
4 |
Correct |
14 ms |
3032 KB |
Output is correct |
5 |
Correct |
30 ms |
3032 KB |
Output is correct |
6 |
Correct |
21 ms |
3032 KB |
Output is correct |
7 |
Correct |
17 ms |
3032 KB |
Output is correct |
8 |
Correct |
28 ms |
3032 KB |
Output is correct |
9 |
Correct |
25 ms |
3080 KB |
Output is correct |
10 |
Correct |
62 ms |
3084 KB |
Output is correct |
11 |
Correct |
68 ms |
3084 KB |
Output is correct |
12 |
Correct |
64 ms |
3084 KB |
Output is correct |
13 |
Correct |
55 ms |
3084 KB |
Output is correct |
14 |
Correct |
59 ms |
3084 KB |
Output is correct |
15 |
Correct |
68 ms |
3084 KB |
Output is correct |
16 |
Correct |
70 ms |
3084 KB |
Output is correct |
17 |
Correct |
40 ms |
3084 KB |
Output is correct |
18 |
Correct |
53 ms |
3116 KB |
Output is correct |
19 |
Correct |
55 ms |
3116 KB |
Output is correct |
20 |
Correct |
66 ms |
3116 KB |
Output is correct |
21 |
Correct |
137 ms |
3160 KB |
Output is correct |
22 |
Correct |
179 ms |
3160 KB |
Output is correct |
23 |
Correct |
110 ms |
3216 KB |
Output is correct |
24 |
Correct |
197 ms |
3216 KB |
Output is correct |
25 |
Correct |
242 ms |
3312 KB |
Output is correct |
26 |
Correct |
217 ms |
3312 KB |
Output is correct |
27 |
Correct |
209 ms |
3312 KB |
Output is correct |
28 |
Correct |
209 ms |
3324 KB |
Output is correct |
29 |
Correct |
204 ms |
3344 KB |
Output is correct |
30 |
Correct |
208 ms |
3344 KB |
Output is correct |
31 |
Correct |
241 ms |
3356 KB |
Output is correct |
32 |
Correct |
215 ms |
3360 KB |
Output is correct |
33 |
Correct |
205 ms |
3364 KB |
Output is correct |
34 |
Correct |
226 ms |
3368 KB |
Output is correct |
35 |
Correct |
226 ms |
3372 KB |
Output is correct |
36 |
Correct |
203 ms |
3536 KB |
Output is correct |
37 |
Correct |
483 ms |
3600 KB |
Output is correct |
38 |
Correct |
444 ms |
3672 KB |
Output is correct |
39 |
Correct |
516 ms |
3672 KB |
Output is correct |
40 |
Correct |
688 ms |
3744 KB |
Output is correct |
41 |
Correct |
545 ms |
3744 KB |
Output is correct |
42 |
Correct |
638 ms |
3816 KB |
Output is correct |
43 |
Correct |
654 ms |
3948 KB |
Output is correct |
44 |
Correct |
695 ms |
3948 KB |
Output is correct |
45 |
Correct |
645 ms |
3948 KB |
Output is correct |
46 |
Correct |
620 ms |
3948 KB |
Output is correct |
47 |
Correct |
602 ms |
3948 KB |
Output is correct |
48 |
Correct |
634 ms |
3968 KB |
Output is correct |
49 |
Correct |
624 ms |
3968 KB |
Output is correct |
50 |
Correct |
649 ms |
3968 KB |
Output is correct |
51 |
Correct |
122 ms |
3968 KB |
Output is correct |
52 |
Correct |
748 ms |
3968 KB |
Output is correct |
53 |
Correct |
814 ms |
3968 KB |
Output is correct |
54 |
Execution timed out |
1002 ms |
3996 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2680 KB |
Output is correct |
2 |
Correct |
17 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2848 KB |
Output is correct |
4 |
Correct |
14 ms |
3032 KB |
Output is correct |
5 |
Correct |
30 ms |
3032 KB |
Output is correct |
6 |
Correct |
21 ms |
3032 KB |
Output is correct |
7 |
Correct |
17 ms |
3032 KB |
Output is correct |
8 |
Correct |
28 ms |
3032 KB |
Output is correct |
9 |
Correct |
25 ms |
3080 KB |
Output is correct |
10 |
Correct |
62 ms |
3084 KB |
Output is correct |
11 |
Correct |
68 ms |
3084 KB |
Output is correct |
12 |
Correct |
64 ms |
3084 KB |
Output is correct |
13 |
Correct |
55 ms |
3084 KB |
Output is correct |
14 |
Correct |
59 ms |
3084 KB |
Output is correct |
15 |
Correct |
68 ms |
3084 KB |
Output is correct |
16 |
Correct |
70 ms |
3084 KB |
Output is correct |
17 |
Correct |
40 ms |
3084 KB |
Output is correct |
18 |
Correct |
53 ms |
3116 KB |
Output is correct |
19 |
Correct |
55 ms |
3116 KB |
Output is correct |
20 |
Correct |
66 ms |
3116 KB |
Output is correct |
21 |
Correct |
137 ms |
3160 KB |
Output is correct |
22 |
Correct |
179 ms |
3160 KB |
Output is correct |
23 |
Correct |
110 ms |
3216 KB |
Output is correct |
24 |
Correct |
197 ms |
3216 KB |
Output is correct |
25 |
Correct |
242 ms |
3312 KB |
Output is correct |
26 |
Correct |
217 ms |
3312 KB |
Output is correct |
27 |
Correct |
209 ms |
3312 KB |
Output is correct |
28 |
Correct |
209 ms |
3324 KB |
Output is correct |
29 |
Correct |
204 ms |
3344 KB |
Output is correct |
30 |
Correct |
208 ms |
3344 KB |
Output is correct |
31 |
Correct |
241 ms |
3356 KB |
Output is correct |
32 |
Correct |
215 ms |
3360 KB |
Output is correct |
33 |
Correct |
205 ms |
3364 KB |
Output is correct |
34 |
Correct |
226 ms |
3368 KB |
Output is correct |
35 |
Correct |
226 ms |
3372 KB |
Output is correct |
36 |
Correct |
203 ms |
3536 KB |
Output is correct |
37 |
Correct |
483 ms |
3600 KB |
Output is correct |
38 |
Correct |
444 ms |
3672 KB |
Output is correct |
39 |
Correct |
516 ms |
3672 KB |
Output is correct |
40 |
Correct |
688 ms |
3744 KB |
Output is correct |
41 |
Correct |
545 ms |
3744 KB |
Output is correct |
42 |
Correct |
638 ms |
3816 KB |
Output is correct |
43 |
Correct |
654 ms |
3948 KB |
Output is correct |
44 |
Correct |
695 ms |
3948 KB |
Output is correct |
45 |
Correct |
645 ms |
3948 KB |
Output is correct |
46 |
Correct |
620 ms |
3948 KB |
Output is correct |
47 |
Correct |
602 ms |
3948 KB |
Output is correct |
48 |
Correct |
634 ms |
3968 KB |
Output is correct |
49 |
Correct |
624 ms |
3968 KB |
Output is correct |
50 |
Correct |
649 ms |
3968 KB |
Output is correct |
51 |
Correct |
122 ms |
3968 KB |
Output is correct |
52 |
Correct |
748 ms |
3968 KB |
Output is correct |
53 |
Correct |
814 ms |
3968 KB |
Output is correct |
54 |
Execution timed out |
1002 ms |
3996 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |