#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in array<int, 2>
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 2543568463;
const int SMX = 2e5+5e4+10;
const int MX = 5e5+10;
int dp[MX];
void add(int x)
{
for(int i = MX-1; i >= x; i--)
{
dp[i]+=dp[i-x];
dp[i]%=mod;
}
return;
}
void rem(int x)
{
for(int i = x; i < MX; i++)
{
dp[i]-=dp[i-x]; dp[i]+=mod;
dp[i]%=mod;
}
return;
}
int cnt[SMX];
signed main()
{
fast();
dp[0] = 1;
int n;
cin >> n;
int S = 0;
vector<int> a(n+1);
for(int i = 1; i <= n; i++)
{
cin >> a[i]; S+=a[i];
add(a[i]);
}
if(S%2 || (dp[S/2] == 0))
{
cout << "0\n";
return 0;
}
for(int i = 1; i <= n; i++)
{
rem(a[i]);
for(int V = 0; V < SMX; V++)
{
int D = S+V-a[i];
if(D%2)
continue;
if(dp[(D/2)] || ((D >= 2*V) && ((dp[(D/2)-V]))))
cnt[V]++;
}
add(a[i]);
}
vector<int> v;
for(int i = 0; i < SMX; i++)
{
if(cnt[i] == n)
v.pb(i);
}
cout << v.size() << "\n";
for(int x: v)
cout << x << " ";
cout << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
6236 KB |
Output is correct |
2 |
Correct |
15 ms |
5980 KB |
Output is correct |
3 |
Correct |
4 ms |
5980 KB |
Output is correct |
4 |
Correct |
11 ms |
5980 KB |
Output is correct |
5 |
Correct |
27 ms |
5980 KB |
Output is correct |
6 |
Correct |
19 ms |
5980 KB |
Output is correct |
7 |
Correct |
15 ms |
5980 KB |
Output is correct |
8 |
Correct |
27 ms |
6164 KB |
Output is correct |
9 |
Correct |
24 ms |
5980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
6236 KB |
Output is correct |
2 |
Correct |
15 ms |
5980 KB |
Output is correct |
3 |
Correct |
4 ms |
5980 KB |
Output is correct |
4 |
Correct |
11 ms |
5980 KB |
Output is correct |
5 |
Correct |
27 ms |
5980 KB |
Output is correct |
6 |
Correct |
19 ms |
5980 KB |
Output is correct |
7 |
Correct |
15 ms |
5980 KB |
Output is correct |
8 |
Correct |
27 ms |
6164 KB |
Output is correct |
9 |
Correct |
24 ms |
5980 KB |
Output is correct |
10 |
Correct |
65 ms |
5980 KB |
Output is correct |
11 |
Correct |
72 ms |
5980 KB |
Output is correct |
12 |
Correct |
65 ms |
5980 KB |
Output is correct |
13 |
Correct |
60 ms |
6120 KB |
Output is correct |
14 |
Correct |
62 ms |
6124 KB |
Output is correct |
15 |
Correct |
69 ms |
5980 KB |
Output is correct |
16 |
Correct |
79 ms |
6128 KB |
Output is correct |
17 |
Correct |
43 ms |
5976 KB |
Output is correct |
18 |
Correct |
56 ms |
5980 KB |
Output is correct |
19 |
Correct |
63 ms |
6128 KB |
Output is correct |
20 |
Correct |
63 ms |
5980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
6236 KB |
Output is correct |
2 |
Correct |
15 ms |
5980 KB |
Output is correct |
3 |
Correct |
4 ms |
5980 KB |
Output is correct |
4 |
Correct |
11 ms |
5980 KB |
Output is correct |
5 |
Correct |
27 ms |
5980 KB |
Output is correct |
6 |
Correct |
19 ms |
5980 KB |
Output is correct |
7 |
Correct |
15 ms |
5980 KB |
Output is correct |
8 |
Correct |
27 ms |
6164 KB |
Output is correct |
9 |
Correct |
24 ms |
5980 KB |
Output is correct |
10 |
Correct |
65 ms |
5980 KB |
Output is correct |
11 |
Correct |
72 ms |
5980 KB |
Output is correct |
12 |
Correct |
65 ms |
5980 KB |
Output is correct |
13 |
Correct |
60 ms |
6120 KB |
Output is correct |
14 |
Correct |
62 ms |
6124 KB |
Output is correct |
15 |
Correct |
69 ms |
5980 KB |
Output is correct |
16 |
Correct |
79 ms |
6128 KB |
Output is correct |
17 |
Correct |
43 ms |
5976 KB |
Output is correct |
18 |
Correct |
56 ms |
5980 KB |
Output is correct |
19 |
Correct |
63 ms |
6128 KB |
Output is correct |
20 |
Correct |
63 ms |
5980 KB |
Output is correct |
21 |
Correct |
144 ms |
6144 KB |
Output is correct |
22 |
Correct |
179 ms |
6136 KB |
Output is correct |
23 |
Correct |
114 ms |
5980 KB |
Output is correct |
24 |
Correct |
213 ms |
6228 KB |
Output is correct |
25 |
Correct |
217 ms |
6196 KB |
Output is correct |
26 |
Correct |
220 ms |
6200 KB |
Output is correct |
27 |
Correct |
223 ms |
6192 KB |
Output is correct |
28 |
Correct |
206 ms |
6196 KB |
Output is correct |
29 |
Correct |
208 ms |
6140 KB |
Output is correct |
30 |
Correct |
220 ms |
6160 KB |
Output is correct |
31 |
Correct |
222 ms |
6136 KB |
Output is correct |
32 |
Correct |
211 ms |
6140 KB |
Output is correct |
33 |
Correct |
214 ms |
6304 KB |
Output is correct |
34 |
Correct |
206 ms |
6136 KB |
Output is correct |
35 |
Correct |
219 ms |
5980 KB |
Output is correct |
36 |
Correct |
213 ms |
6228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
6236 KB |
Output is correct |
2 |
Correct |
15 ms |
5980 KB |
Output is correct |
3 |
Correct |
4 ms |
5980 KB |
Output is correct |
4 |
Correct |
11 ms |
5980 KB |
Output is correct |
5 |
Correct |
27 ms |
5980 KB |
Output is correct |
6 |
Correct |
19 ms |
5980 KB |
Output is correct |
7 |
Correct |
15 ms |
5980 KB |
Output is correct |
8 |
Correct |
27 ms |
6164 KB |
Output is correct |
9 |
Correct |
24 ms |
5980 KB |
Output is correct |
10 |
Correct |
65 ms |
5980 KB |
Output is correct |
11 |
Correct |
72 ms |
5980 KB |
Output is correct |
12 |
Correct |
65 ms |
5980 KB |
Output is correct |
13 |
Correct |
60 ms |
6120 KB |
Output is correct |
14 |
Correct |
62 ms |
6124 KB |
Output is correct |
15 |
Correct |
69 ms |
5980 KB |
Output is correct |
16 |
Correct |
79 ms |
6128 KB |
Output is correct |
17 |
Correct |
43 ms |
5976 KB |
Output is correct |
18 |
Correct |
56 ms |
5980 KB |
Output is correct |
19 |
Correct |
63 ms |
6128 KB |
Output is correct |
20 |
Correct |
63 ms |
5980 KB |
Output is correct |
21 |
Correct |
144 ms |
6144 KB |
Output is correct |
22 |
Correct |
179 ms |
6136 KB |
Output is correct |
23 |
Correct |
114 ms |
5980 KB |
Output is correct |
24 |
Correct |
213 ms |
6228 KB |
Output is correct |
25 |
Correct |
217 ms |
6196 KB |
Output is correct |
26 |
Correct |
220 ms |
6200 KB |
Output is correct |
27 |
Correct |
223 ms |
6192 KB |
Output is correct |
28 |
Correct |
206 ms |
6196 KB |
Output is correct |
29 |
Correct |
208 ms |
6140 KB |
Output is correct |
30 |
Correct |
220 ms |
6160 KB |
Output is correct |
31 |
Correct |
222 ms |
6136 KB |
Output is correct |
32 |
Correct |
211 ms |
6140 KB |
Output is correct |
33 |
Correct |
214 ms |
6304 KB |
Output is correct |
34 |
Correct |
206 ms |
6136 KB |
Output is correct |
35 |
Correct |
219 ms |
5980 KB |
Output is correct |
36 |
Correct |
213 ms |
6228 KB |
Output is correct |
37 |
Correct |
439 ms |
6528 KB |
Output is correct |
38 |
Correct |
422 ms |
6484 KB |
Output is correct |
39 |
Correct |
529 ms |
6480 KB |
Output is correct |
40 |
Correct |
558 ms |
6640 KB |
Output is correct |
41 |
Correct |
556 ms |
6296 KB |
Output is correct |
42 |
Correct |
544 ms |
6632 KB |
Output is correct |
43 |
Correct |
518 ms |
6760 KB |
Output is correct |
44 |
Correct |
514 ms |
6608 KB |
Output is correct |
45 |
Correct |
572 ms |
6780 KB |
Output is correct |
46 |
Correct |
584 ms |
6308 KB |
Output is correct |
47 |
Correct |
515 ms |
6484 KB |
Output is correct |
48 |
Correct |
558 ms |
6680 KB |
Output is correct |
49 |
Correct |
554 ms |
6296 KB |
Output is correct |
50 |
Correct |
521 ms |
6636 KB |
Output is correct |
51 |
Correct |
153 ms |
6128 KB |
Output is correct |
52 |
Correct |
585 ms |
6776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
6236 KB |
Output is correct |
2 |
Correct |
15 ms |
5980 KB |
Output is correct |
3 |
Correct |
4 ms |
5980 KB |
Output is correct |
4 |
Correct |
11 ms |
5980 KB |
Output is correct |
5 |
Correct |
27 ms |
5980 KB |
Output is correct |
6 |
Correct |
19 ms |
5980 KB |
Output is correct |
7 |
Correct |
15 ms |
5980 KB |
Output is correct |
8 |
Correct |
27 ms |
6164 KB |
Output is correct |
9 |
Correct |
24 ms |
5980 KB |
Output is correct |
10 |
Correct |
65 ms |
5980 KB |
Output is correct |
11 |
Correct |
72 ms |
5980 KB |
Output is correct |
12 |
Correct |
65 ms |
5980 KB |
Output is correct |
13 |
Correct |
60 ms |
6120 KB |
Output is correct |
14 |
Correct |
62 ms |
6124 KB |
Output is correct |
15 |
Correct |
69 ms |
5980 KB |
Output is correct |
16 |
Correct |
79 ms |
6128 KB |
Output is correct |
17 |
Correct |
43 ms |
5976 KB |
Output is correct |
18 |
Correct |
56 ms |
5980 KB |
Output is correct |
19 |
Correct |
63 ms |
6128 KB |
Output is correct |
20 |
Correct |
63 ms |
5980 KB |
Output is correct |
21 |
Correct |
144 ms |
6144 KB |
Output is correct |
22 |
Correct |
179 ms |
6136 KB |
Output is correct |
23 |
Correct |
114 ms |
5980 KB |
Output is correct |
24 |
Correct |
213 ms |
6228 KB |
Output is correct |
25 |
Correct |
217 ms |
6196 KB |
Output is correct |
26 |
Correct |
220 ms |
6200 KB |
Output is correct |
27 |
Correct |
223 ms |
6192 KB |
Output is correct |
28 |
Correct |
206 ms |
6196 KB |
Output is correct |
29 |
Correct |
208 ms |
6140 KB |
Output is correct |
30 |
Correct |
220 ms |
6160 KB |
Output is correct |
31 |
Correct |
222 ms |
6136 KB |
Output is correct |
32 |
Correct |
211 ms |
6140 KB |
Output is correct |
33 |
Correct |
214 ms |
6304 KB |
Output is correct |
34 |
Correct |
206 ms |
6136 KB |
Output is correct |
35 |
Correct |
219 ms |
5980 KB |
Output is correct |
36 |
Correct |
213 ms |
6228 KB |
Output is correct |
37 |
Correct |
439 ms |
6528 KB |
Output is correct |
38 |
Correct |
422 ms |
6484 KB |
Output is correct |
39 |
Correct |
529 ms |
6480 KB |
Output is correct |
40 |
Correct |
558 ms |
6640 KB |
Output is correct |
41 |
Correct |
556 ms |
6296 KB |
Output is correct |
42 |
Correct |
544 ms |
6632 KB |
Output is correct |
43 |
Correct |
518 ms |
6760 KB |
Output is correct |
44 |
Correct |
514 ms |
6608 KB |
Output is correct |
45 |
Correct |
572 ms |
6780 KB |
Output is correct |
46 |
Correct |
584 ms |
6308 KB |
Output is correct |
47 |
Correct |
515 ms |
6484 KB |
Output is correct |
48 |
Correct |
558 ms |
6680 KB |
Output is correct |
49 |
Correct |
554 ms |
6296 KB |
Output is correct |
50 |
Correct |
521 ms |
6636 KB |
Output is correct |
51 |
Correct |
153 ms |
6128 KB |
Output is correct |
52 |
Correct |
585 ms |
6776 KB |
Output is correct |
53 |
Correct |
649 ms |
6740 KB |
Output is correct |
54 |
Correct |
756 ms |
6684 KB |
Output is correct |
55 |
Correct |
751 ms |
7020 KB |
Output is correct |
56 |
Correct |
664 ms |
6780 KB |
Output is correct |
57 |
Correct |
749 ms |
7120 KB |
Output is correct |
58 |
Correct |
736 ms |
6868 KB |
Output is correct |
59 |
Correct |
728 ms |
6864 KB |
Output is correct |
60 |
Correct |
217 ms |
6132 KB |
Output is correct |
61 |
Correct |
761 ms |
6944 KB |
Output is correct |
62 |
Correct |
705 ms |
6944 KB |
Output is correct |
63 |
Correct |
688 ms |
6868 KB |
Output is correct |
64 |
Correct |
660 ms |
7028 KB |
Output is correct |
65 |
Correct |
654 ms |
6308 KB |
Output is correct |
66 |
Correct |
679 ms |
6312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
6236 KB |
Output is correct |
2 |
Correct |
15 ms |
5980 KB |
Output is correct |
3 |
Correct |
4 ms |
5980 KB |
Output is correct |
4 |
Correct |
11 ms |
5980 KB |
Output is correct |
5 |
Correct |
27 ms |
5980 KB |
Output is correct |
6 |
Correct |
19 ms |
5980 KB |
Output is correct |
7 |
Correct |
15 ms |
5980 KB |
Output is correct |
8 |
Correct |
27 ms |
6164 KB |
Output is correct |
9 |
Correct |
24 ms |
5980 KB |
Output is correct |
10 |
Correct |
65 ms |
5980 KB |
Output is correct |
11 |
Correct |
72 ms |
5980 KB |
Output is correct |
12 |
Correct |
65 ms |
5980 KB |
Output is correct |
13 |
Correct |
60 ms |
6120 KB |
Output is correct |
14 |
Correct |
62 ms |
6124 KB |
Output is correct |
15 |
Correct |
69 ms |
5980 KB |
Output is correct |
16 |
Correct |
79 ms |
6128 KB |
Output is correct |
17 |
Correct |
43 ms |
5976 KB |
Output is correct |
18 |
Correct |
56 ms |
5980 KB |
Output is correct |
19 |
Correct |
63 ms |
6128 KB |
Output is correct |
20 |
Correct |
63 ms |
5980 KB |
Output is correct |
21 |
Correct |
144 ms |
6144 KB |
Output is correct |
22 |
Correct |
179 ms |
6136 KB |
Output is correct |
23 |
Correct |
114 ms |
5980 KB |
Output is correct |
24 |
Correct |
213 ms |
6228 KB |
Output is correct |
25 |
Correct |
217 ms |
6196 KB |
Output is correct |
26 |
Correct |
220 ms |
6200 KB |
Output is correct |
27 |
Correct |
223 ms |
6192 KB |
Output is correct |
28 |
Correct |
206 ms |
6196 KB |
Output is correct |
29 |
Correct |
208 ms |
6140 KB |
Output is correct |
30 |
Correct |
220 ms |
6160 KB |
Output is correct |
31 |
Correct |
222 ms |
6136 KB |
Output is correct |
32 |
Correct |
211 ms |
6140 KB |
Output is correct |
33 |
Correct |
214 ms |
6304 KB |
Output is correct |
34 |
Correct |
206 ms |
6136 KB |
Output is correct |
35 |
Correct |
219 ms |
5980 KB |
Output is correct |
36 |
Correct |
213 ms |
6228 KB |
Output is correct |
37 |
Correct |
439 ms |
6528 KB |
Output is correct |
38 |
Correct |
422 ms |
6484 KB |
Output is correct |
39 |
Correct |
529 ms |
6480 KB |
Output is correct |
40 |
Correct |
558 ms |
6640 KB |
Output is correct |
41 |
Correct |
556 ms |
6296 KB |
Output is correct |
42 |
Correct |
544 ms |
6632 KB |
Output is correct |
43 |
Correct |
518 ms |
6760 KB |
Output is correct |
44 |
Correct |
514 ms |
6608 KB |
Output is correct |
45 |
Correct |
572 ms |
6780 KB |
Output is correct |
46 |
Correct |
584 ms |
6308 KB |
Output is correct |
47 |
Correct |
515 ms |
6484 KB |
Output is correct |
48 |
Correct |
558 ms |
6680 KB |
Output is correct |
49 |
Correct |
554 ms |
6296 KB |
Output is correct |
50 |
Correct |
521 ms |
6636 KB |
Output is correct |
51 |
Correct |
153 ms |
6128 KB |
Output is correct |
52 |
Correct |
585 ms |
6776 KB |
Output is correct |
53 |
Correct |
649 ms |
6740 KB |
Output is correct |
54 |
Correct |
756 ms |
6684 KB |
Output is correct |
55 |
Correct |
751 ms |
7020 KB |
Output is correct |
56 |
Correct |
664 ms |
6780 KB |
Output is correct |
57 |
Correct |
749 ms |
7120 KB |
Output is correct |
58 |
Correct |
736 ms |
6868 KB |
Output is correct |
59 |
Correct |
728 ms |
6864 KB |
Output is correct |
60 |
Correct |
217 ms |
6132 KB |
Output is correct |
61 |
Correct |
761 ms |
6944 KB |
Output is correct |
62 |
Correct |
705 ms |
6944 KB |
Output is correct |
63 |
Correct |
688 ms |
6868 KB |
Output is correct |
64 |
Correct |
660 ms |
7028 KB |
Output is correct |
65 |
Correct |
654 ms |
6308 KB |
Output is correct |
66 |
Correct |
679 ms |
6312 KB |
Output is correct |
67 |
Correct |
843 ms |
6948 KB |
Output is correct |
68 |
Correct |
291 ms |
5980 KB |
Output is correct |
69 |
Execution timed out |
1039 ms |
7716 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |