#include <bits/stdc++.h>
using namespace std;
const int N = 502;
int n;
int a[N];
int m;
int u[N * N];
int uu[N * N];
bool t[N][N * N];
int main()
{
//freopen("input2.txt", "r", stdin);
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
m += a[i];
}
u[0] = 1;
for (int i = 1; i <= n; ++i)
{
for (int j = m; j >= 0; --j)
{
if (j + a[i] <= m)
u[j + a[i]] += u[j];
}
}
for (int i = 1; i <= n; ++i)
{
memcpy(uu, u, sizeof u);
for (int j = 0; j <= m; ++j)
{
if (j + a[i] <= m)
uu[j + a[i]] -= uu[j];
}
for (int j = 0; j <= m; ++j)
{
if (uu[j])
t[i][j] = true;
}
}
if ((m % 2) == 1 || !u[m / 2])
{
cout << 0 << endl;
return 0;
}
vector<int> ans;
for (int x = 1; x <= m; ++x)
{
bool z = true;
for (int i = 1; i <= n; ++i)
{
int y = (m - a[i] + x) / 2;
if (!((m - a[i] + x) % 2 == 0 && y <= m && t[i][y]))
{
z = false;
break;
}
}
if (z)
ans.push_back(x);
}
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); ++i)
cout << ans[i] << ' ';
cout << endl;
return 0;
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:73:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < ans.size(); ++i)
~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1404 KB |
Output is correct |
3 |
Correct |
3 ms |
1272 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1276 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1404 KB |
Output is correct |
3 |
Correct |
3 ms |
1272 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1276 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
5 ms |
1400 KB |
Output is correct |
12 |
Correct |
5 ms |
1400 KB |
Output is correct |
13 |
Correct |
5 ms |
1404 KB |
Output is correct |
14 |
Correct |
5 ms |
1400 KB |
Output is correct |
15 |
Correct |
5 ms |
1404 KB |
Output is correct |
16 |
Correct |
5 ms |
1528 KB |
Output is correct |
17 |
Correct |
4 ms |
1400 KB |
Output is correct |
18 |
Correct |
4 ms |
1400 KB |
Output is correct |
19 |
Correct |
4 ms |
1400 KB |
Output is correct |
20 |
Correct |
5 ms |
1528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1404 KB |
Output is correct |
3 |
Correct |
3 ms |
1272 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1276 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
5 ms |
1400 KB |
Output is correct |
12 |
Correct |
5 ms |
1400 KB |
Output is correct |
13 |
Correct |
5 ms |
1404 KB |
Output is correct |
14 |
Correct |
5 ms |
1400 KB |
Output is correct |
15 |
Correct |
5 ms |
1404 KB |
Output is correct |
16 |
Correct |
5 ms |
1528 KB |
Output is correct |
17 |
Correct |
4 ms |
1400 KB |
Output is correct |
18 |
Correct |
4 ms |
1400 KB |
Output is correct |
19 |
Correct |
4 ms |
1400 KB |
Output is correct |
20 |
Correct |
5 ms |
1528 KB |
Output is correct |
21 |
Correct |
8 ms |
1788 KB |
Output is correct |
22 |
Correct |
9 ms |
1912 KB |
Output is correct |
23 |
Correct |
7 ms |
1720 KB |
Output is correct |
24 |
Correct |
11 ms |
2172 KB |
Output is correct |
25 |
Correct |
13 ms |
2680 KB |
Output is correct |
26 |
Correct |
13 ms |
2808 KB |
Output is correct |
27 |
Correct |
12 ms |
2680 KB |
Output is correct |
28 |
Correct |
13 ms |
2680 KB |
Output is correct |
29 |
Correct |
12 ms |
2680 KB |
Output is correct |
30 |
Correct |
11 ms |
2296 KB |
Output is correct |
31 |
Correct |
12 ms |
2552 KB |
Output is correct |
32 |
Correct |
12 ms |
2296 KB |
Output is correct |
33 |
Correct |
12 ms |
2808 KB |
Output is correct |
34 |
Correct |
12 ms |
2680 KB |
Output is correct |
35 |
Correct |
12 ms |
2684 KB |
Output is correct |
36 |
Correct |
11 ms |
2276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1404 KB |
Output is correct |
3 |
Correct |
3 ms |
1272 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1276 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
5 ms |
1400 KB |
Output is correct |
12 |
Correct |
5 ms |
1400 KB |
Output is correct |
13 |
Correct |
5 ms |
1404 KB |
Output is correct |
14 |
Correct |
5 ms |
1400 KB |
Output is correct |
15 |
Correct |
5 ms |
1404 KB |
Output is correct |
16 |
Correct |
5 ms |
1528 KB |
Output is correct |
17 |
Correct |
4 ms |
1400 KB |
Output is correct |
18 |
Correct |
4 ms |
1400 KB |
Output is correct |
19 |
Correct |
4 ms |
1400 KB |
Output is correct |
20 |
Correct |
5 ms |
1528 KB |
Output is correct |
21 |
Correct |
8 ms |
1788 KB |
Output is correct |
22 |
Correct |
9 ms |
1912 KB |
Output is correct |
23 |
Correct |
7 ms |
1720 KB |
Output is correct |
24 |
Correct |
11 ms |
2172 KB |
Output is correct |
25 |
Correct |
13 ms |
2680 KB |
Output is correct |
26 |
Correct |
13 ms |
2808 KB |
Output is correct |
27 |
Correct |
12 ms |
2680 KB |
Output is correct |
28 |
Correct |
13 ms |
2680 KB |
Output is correct |
29 |
Correct |
12 ms |
2680 KB |
Output is correct |
30 |
Correct |
11 ms |
2296 KB |
Output is correct |
31 |
Correct |
12 ms |
2552 KB |
Output is correct |
32 |
Correct |
12 ms |
2296 KB |
Output is correct |
33 |
Correct |
12 ms |
2808 KB |
Output is correct |
34 |
Correct |
12 ms |
2680 KB |
Output is correct |
35 |
Correct |
12 ms |
2684 KB |
Output is correct |
36 |
Correct |
11 ms |
2276 KB |
Output is correct |
37 |
Correct |
33 ms |
6264 KB |
Output is correct |
38 |
Correct |
35 ms |
6264 KB |
Output is correct |
39 |
Correct |
68 ms |
17632 KB |
Output is correct |
40 |
Correct |
62 ms |
11384 KB |
Output is correct |
41 |
Correct |
83 ms |
21924 KB |
Output is correct |
42 |
Correct |
54 ms |
10104 KB |
Output is correct |
43 |
Correct |
83 ms |
16124 KB |
Output is correct |
44 |
Correct |
87 ms |
16612 KB |
Output is correct |
45 |
Correct |
91 ms |
16760 KB |
Output is correct |
46 |
Correct |
46 ms |
11000 KB |
Output is correct |
47 |
Correct |
59 ms |
10744 KB |
Output is correct |
48 |
Correct |
86 ms |
18040 KB |
Output is correct |
49 |
Correct |
71 ms |
17784 KB |
Output is correct |
50 |
Correct |
59 ms |
10744 KB |
Output is correct |
51 |
Correct |
42 ms |
10204 KB |
Output is correct |
52 |
Correct |
113 ms |
21624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1404 KB |
Output is correct |
3 |
Correct |
3 ms |
1272 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1276 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
5 ms |
1400 KB |
Output is correct |
12 |
Correct |
5 ms |
1400 KB |
Output is correct |
13 |
Correct |
5 ms |
1404 KB |
Output is correct |
14 |
Correct |
5 ms |
1400 KB |
Output is correct |
15 |
Correct |
5 ms |
1404 KB |
Output is correct |
16 |
Correct |
5 ms |
1528 KB |
Output is correct |
17 |
Correct |
4 ms |
1400 KB |
Output is correct |
18 |
Correct |
4 ms |
1400 KB |
Output is correct |
19 |
Correct |
4 ms |
1400 KB |
Output is correct |
20 |
Correct |
5 ms |
1528 KB |
Output is correct |
21 |
Correct |
8 ms |
1788 KB |
Output is correct |
22 |
Correct |
9 ms |
1912 KB |
Output is correct |
23 |
Correct |
7 ms |
1720 KB |
Output is correct |
24 |
Correct |
11 ms |
2172 KB |
Output is correct |
25 |
Correct |
13 ms |
2680 KB |
Output is correct |
26 |
Correct |
13 ms |
2808 KB |
Output is correct |
27 |
Correct |
12 ms |
2680 KB |
Output is correct |
28 |
Correct |
13 ms |
2680 KB |
Output is correct |
29 |
Correct |
12 ms |
2680 KB |
Output is correct |
30 |
Correct |
11 ms |
2296 KB |
Output is correct |
31 |
Correct |
12 ms |
2552 KB |
Output is correct |
32 |
Correct |
12 ms |
2296 KB |
Output is correct |
33 |
Correct |
12 ms |
2808 KB |
Output is correct |
34 |
Correct |
12 ms |
2680 KB |
Output is correct |
35 |
Correct |
12 ms |
2684 KB |
Output is correct |
36 |
Correct |
11 ms |
2276 KB |
Output is correct |
37 |
Correct |
33 ms |
6264 KB |
Output is correct |
38 |
Correct |
35 ms |
6264 KB |
Output is correct |
39 |
Correct |
68 ms |
17632 KB |
Output is correct |
40 |
Correct |
62 ms |
11384 KB |
Output is correct |
41 |
Correct |
83 ms |
21924 KB |
Output is correct |
42 |
Correct |
54 ms |
10104 KB |
Output is correct |
43 |
Correct |
83 ms |
16124 KB |
Output is correct |
44 |
Correct |
87 ms |
16612 KB |
Output is correct |
45 |
Correct |
91 ms |
16760 KB |
Output is correct |
46 |
Correct |
46 ms |
11000 KB |
Output is correct |
47 |
Correct |
59 ms |
10744 KB |
Output is correct |
48 |
Correct |
86 ms |
18040 KB |
Output is correct |
49 |
Correct |
71 ms |
17784 KB |
Output is correct |
50 |
Correct |
59 ms |
10744 KB |
Output is correct |
51 |
Correct |
42 ms |
10204 KB |
Output is correct |
52 |
Correct |
113 ms |
21624 KB |
Output is correct |
53 |
Correct |
89 ms |
16604 KB |
Output is correct |
54 |
Correct |
120 ms |
22360 KB |
Output is correct |
55 |
Correct |
201 ms |
41748 KB |
Output is correct |
56 |
Correct |
110 ms |
19932 KB |
Output is correct |
57 |
Correct |
222 ms |
43900 KB |
Output is correct |
58 |
Correct |
133 ms |
24428 KB |
Output is correct |
59 |
Correct |
164 ms |
29708 KB |
Output is correct |
60 |
Correct |
87 ms |
24056 KB |
Output is correct |
61 |
Correct |
170 ms |
32948 KB |
Output is correct |
62 |
Correct |
171 ms |
33636 KB |
Output is correct |
63 |
Correct |
183 ms |
36172 KB |
Output is correct |
64 |
Correct |
183 ms |
34956 KB |
Output is correct |
65 |
Correct |
73 ms |
17784 KB |
Output is correct |
66 |
Correct |
80 ms |
19064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1404 KB |
Output is correct |
3 |
Correct |
3 ms |
1272 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1276 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
5 ms |
1400 KB |
Output is correct |
12 |
Correct |
5 ms |
1400 KB |
Output is correct |
13 |
Correct |
5 ms |
1404 KB |
Output is correct |
14 |
Correct |
5 ms |
1400 KB |
Output is correct |
15 |
Correct |
5 ms |
1404 KB |
Output is correct |
16 |
Correct |
5 ms |
1528 KB |
Output is correct |
17 |
Correct |
4 ms |
1400 KB |
Output is correct |
18 |
Correct |
4 ms |
1400 KB |
Output is correct |
19 |
Correct |
4 ms |
1400 KB |
Output is correct |
20 |
Correct |
5 ms |
1528 KB |
Output is correct |
21 |
Correct |
8 ms |
1788 KB |
Output is correct |
22 |
Correct |
9 ms |
1912 KB |
Output is correct |
23 |
Correct |
7 ms |
1720 KB |
Output is correct |
24 |
Correct |
11 ms |
2172 KB |
Output is correct |
25 |
Correct |
13 ms |
2680 KB |
Output is correct |
26 |
Correct |
13 ms |
2808 KB |
Output is correct |
27 |
Correct |
12 ms |
2680 KB |
Output is correct |
28 |
Correct |
13 ms |
2680 KB |
Output is correct |
29 |
Correct |
12 ms |
2680 KB |
Output is correct |
30 |
Correct |
11 ms |
2296 KB |
Output is correct |
31 |
Correct |
12 ms |
2552 KB |
Output is correct |
32 |
Correct |
12 ms |
2296 KB |
Output is correct |
33 |
Correct |
12 ms |
2808 KB |
Output is correct |
34 |
Correct |
12 ms |
2680 KB |
Output is correct |
35 |
Correct |
12 ms |
2684 KB |
Output is correct |
36 |
Correct |
11 ms |
2276 KB |
Output is correct |
37 |
Correct |
33 ms |
6264 KB |
Output is correct |
38 |
Correct |
35 ms |
6264 KB |
Output is correct |
39 |
Correct |
68 ms |
17632 KB |
Output is correct |
40 |
Correct |
62 ms |
11384 KB |
Output is correct |
41 |
Correct |
83 ms |
21924 KB |
Output is correct |
42 |
Correct |
54 ms |
10104 KB |
Output is correct |
43 |
Correct |
83 ms |
16124 KB |
Output is correct |
44 |
Correct |
87 ms |
16612 KB |
Output is correct |
45 |
Correct |
91 ms |
16760 KB |
Output is correct |
46 |
Correct |
46 ms |
11000 KB |
Output is correct |
47 |
Correct |
59 ms |
10744 KB |
Output is correct |
48 |
Correct |
86 ms |
18040 KB |
Output is correct |
49 |
Correct |
71 ms |
17784 KB |
Output is correct |
50 |
Correct |
59 ms |
10744 KB |
Output is correct |
51 |
Correct |
42 ms |
10204 KB |
Output is correct |
52 |
Correct |
113 ms |
21624 KB |
Output is correct |
53 |
Correct |
89 ms |
16604 KB |
Output is correct |
54 |
Correct |
120 ms |
22360 KB |
Output is correct |
55 |
Correct |
201 ms |
41748 KB |
Output is correct |
56 |
Correct |
110 ms |
19932 KB |
Output is correct |
57 |
Correct |
222 ms |
43900 KB |
Output is correct |
58 |
Correct |
133 ms |
24428 KB |
Output is correct |
59 |
Correct |
164 ms |
29708 KB |
Output is correct |
60 |
Correct |
87 ms |
24056 KB |
Output is correct |
61 |
Correct |
170 ms |
32948 KB |
Output is correct |
62 |
Correct |
171 ms |
33636 KB |
Output is correct |
63 |
Correct |
183 ms |
36172 KB |
Output is correct |
64 |
Correct |
183 ms |
34956 KB |
Output is correct |
65 |
Correct |
73 ms |
17784 KB |
Output is correct |
66 |
Correct |
80 ms |
19064 KB |
Output is correct |
67 |
Correct |
173 ms |
35072 KB |
Output is correct |
68 |
Correct |
204 ms |
64120 KB |
Output is correct |
69 |
Correct |
497 ms |
108812 KB |
Output is correct |
70 |
Correct |
324 ms |
67316 KB |
Output is correct |
71 |
Correct |
332 ms |
65384 KB |
Output is correct |
72 |
Correct |
201 ms |
65144 KB |
Output is correct |
73 |
Correct |
243 ms |
64728 KB |
Output is correct |
74 |
Correct |
547 ms |
114392 KB |
Output is correct |
75 |
Correct |
436 ms |
89888 KB |
Output is correct |
76 |
Correct |
553 ms |
124876 KB |
Output is correct |
77 |
Correct |
620 ms |
121464 KB |
Output is correct |