#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int a[N],b[N],q[N],dp[N],n,sum;
int used[N];
void add(int x){
int i;
for (i=sum;i>=0;--i){
dp[i+x]+=dp[i];
}
ret ;
}
void del(int x){
int i;
for (i=0;i<=sum;++i){
dp[i+x]-=dp[i];
}
ret ;
}
main(){
int i,j,x;
scan1(n)
dp[0]=1;
for (i=1;i<=n;++i){
scan1(q[i])
add(q[i]);
sum+=q[i];
}
if(sum&1 || !dp[sum/2]){
cout << 0 << endl;
return 0;
}
for (i=1;i<=n;++i){
del(q[i]);
sum-=q[i];
for (j=sum/2;j<=sum;++j){
if (dp[j] && j*2 > sum)
used[j*2-sum]++;
}
sum+=q[i];
add(q[i]);
}
vector <int> ans;
for (x=1;x<=sum;++x){
if (used[x]==n)ans.pb(x);
}
cout <<ans.size()<<"\n";
for (i=0;i<ans.size();++i){
cout <<ans[i]<<" ";
}
}
Compilation message
bootfall.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
34 | main(){
| ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:65:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for (i=0;i<ans.size();++i){
| ~^~~~~~~~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
9 | #define scan1(a) scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
bootfall.cpp:36:5: note: in expansion of macro 'scan1'
36 | scan1(n)
| ^~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
9 | #define scan1(a) scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
bootfall.cpp:39:9: note: in expansion of macro 'scan1'
39 | scan1(q[i])
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
492 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
3 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
620 KB |
Output is correct |
27 |
Correct |
3 ms |
492 KB |
Output is correct |
28 |
Correct |
3 ms |
492 KB |
Output is correct |
29 |
Correct |
3 ms |
492 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
4 ms |
492 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
4 ms |
492 KB |
Output is correct |
34 |
Correct |
3 ms |
492 KB |
Output is correct |
35 |
Correct |
3 ms |
492 KB |
Output is correct |
36 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
492 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
3 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
620 KB |
Output is correct |
27 |
Correct |
3 ms |
492 KB |
Output is correct |
28 |
Correct |
3 ms |
492 KB |
Output is correct |
29 |
Correct |
3 ms |
492 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
4 ms |
492 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
4 ms |
492 KB |
Output is correct |
34 |
Correct |
3 ms |
492 KB |
Output is correct |
35 |
Correct |
3 ms |
492 KB |
Output is correct |
36 |
Correct |
2 ms |
492 KB |
Output is correct |
37 |
Correct |
11 ms |
876 KB |
Output is correct |
38 |
Correct |
11 ms |
876 KB |
Output is correct |
39 |
Correct |
39 ms |
1260 KB |
Output is correct |
40 |
Correct |
23 ms |
1260 KB |
Output is correct |
41 |
Correct |
49 ms |
1516 KB |
Output is correct |
42 |
Correct |
19 ms |
1132 KB |
Output is correct |
43 |
Correct |
36 ms |
1772 KB |
Output is correct |
44 |
Correct |
40 ms |
1768 KB |
Output is correct |
45 |
Correct |
36 ms |
1768 KB |
Output is correct |
46 |
Correct |
25 ms |
876 KB |
Output is correct |
47 |
Correct |
21 ms |
1260 KB |
Output is correct |
48 |
Correct |
40 ms |
1644 KB |
Output is correct |
49 |
Correct |
42 ms |
1388 KB |
Output is correct |
50 |
Correct |
22 ms |
1260 KB |
Output is correct |
51 |
Correct |
7 ms |
620 KB |
Output is correct |
52 |
Correct |
49 ms |
2024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
492 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
3 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
620 KB |
Output is correct |
27 |
Correct |
3 ms |
492 KB |
Output is correct |
28 |
Correct |
3 ms |
492 KB |
Output is correct |
29 |
Correct |
3 ms |
492 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
4 ms |
492 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
4 ms |
492 KB |
Output is correct |
34 |
Correct |
3 ms |
492 KB |
Output is correct |
35 |
Correct |
3 ms |
492 KB |
Output is correct |
36 |
Correct |
2 ms |
492 KB |
Output is correct |
37 |
Correct |
11 ms |
876 KB |
Output is correct |
38 |
Correct |
11 ms |
876 KB |
Output is correct |
39 |
Correct |
39 ms |
1260 KB |
Output is correct |
40 |
Correct |
23 ms |
1260 KB |
Output is correct |
41 |
Correct |
49 ms |
1516 KB |
Output is correct |
42 |
Correct |
19 ms |
1132 KB |
Output is correct |
43 |
Correct |
36 ms |
1772 KB |
Output is correct |
44 |
Correct |
40 ms |
1768 KB |
Output is correct |
45 |
Correct |
36 ms |
1768 KB |
Output is correct |
46 |
Correct |
25 ms |
876 KB |
Output is correct |
47 |
Correct |
21 ms |
1260 KB |
Output is correct |
48 |
Correct |
40 ms |
1644 KB |
Output is correct |
49 |
Correct |
42 ms |
1388 KB |
Output is correct |
50 |
Correct |
22 ms |
1260 KB |
Output is correct |
51 |
Correct |
7 ms |
620 KB |
Output is correct |
52 |
Correct |
49 ms |
2024 KB |
Output is correct |
53 |
Correct |
35 ms |
1512 KB |
Output is correct |
54 |
Correct |
51 ms |
1768 KB |
Output is correct |
55 |
Correct |
96 ms |
2916 KB |
Output is correct |
56 |
Correct |
43 ms |
1768 KB |
Output is correct |
57 |
Correct |
102 ms |
3044 KB |
Output is correct |
58 |
Correct |
53 ms |
1896 KB |
Output is correct |
59 |
Correct |
67 ms |
2280 KB |
Output is correct |
60 |
Correct |
12 ms |
1004 KB |
Output is correct |
61 |
Correct |
76 ms |
2404 KB |
Output is correct |
62 |
Correct |
76 ms |
2660 KB |
Output is correct |
63 |
Correct |
83 ms |
2788 KB |
Output is correct |
64 |
Correct |
82 ms |
2804 KB |
Output is correct |
65 |
Correct |
41 ms |
1132 KB |
Output is correct |
66 |
Correct |
41 ms |
1260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
492 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
3 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
620 KB |
Output is correct |
27 |
Correct |
3 ms |
492 KB |
Output is correct |
28 |
Correct |
3 ms |
492 KB |
Output is correct |
29 |
Correct |
3 ms |
492 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
4 ms |
492 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
4 ms |
492 KB |
Output is correct |
34 |
Correct |
3 ms |
492 KB |
Output is correct |
35 |
Correct |
3 ms |
492 KB |
Output is correct |
36 |
Correct |
2 ms |
492 KB |
Output is correct |
37 |
Correct |
11 ms |
876 KB |
Output is correct |
38 |
Correct |
11 ms |
876 KB |
Output is correct |
39 |
Correct |
39 ms |
1260 KB |
Output is correct |
40 |
Correct |
23 ms |
1260 KB |
Output is correct |
41 |
Correct |
49 ms |
1516 KB |
Output is correct |
42 |
Correct |
19 ms |
1132 KB |
Output is correct |
43 |
Correct |
36 ms |
1772 KB |
Output is correct |
44 |
Correct |
40 ms |
1768 KB |
Output is correct |
45 |
Correct |
36 ms |
1768 KB |
Output is correct |
46 |
Correct |
25 ms |
876 KB |
Output is correct |
47 |
Correct |
21 ms |
1260 KB |
Output is correct |
48 |
Correct |
40 ms |
1644 KB |
Output is correct |
49 |
Correct |
42 ms |
1388 KB |
Output is correct |
50 |
Correct |
22 ms |
1260 KB |
Output is correct |
51 |
Correct |
7 ms |
620 KB |
Output is correct |
52 |
Correct |
49 ms |
2024 KB |
Output is correct |
53 |
Correct |
35 ms |
1512 KB |
Output is correct |
54 |
Correct |
51 ms |
1768 KB |
Output is correct |
55 |
Correct |
96 ms |
2916 KB |
Output is correct |
56 |
Correct |
43 ms |
1768 KB |
Output is correct |
57 |
Correct |
102 ms |
3044 KB |
Output is correct |
58 |
Correct |
53 ms |
1896 KB |
Output is correct |
59 |
Correct |
67 ms |
2280 KB |
Output is correct |
60 |
Correct |
12 ms |
1004 KB |
Output is correct |
61 |
Correct |
76 ms |
2404 KB |
Output is correct |
62 |
Correct |
76 ms |
2660 KB |
Output is correct |
63 |
Correct |
83 ms |
2788 KB |
Output is correct |
64 |
Correct |
82 ms |
2804 KB |
Output is correct |
65 |
Correct |
41 ms |
1132 KB |
Output is correct |
66 |
Correct |
41 ms |
1260 KB |
Output is correct |
67 |
Correct |
76 ms |
2280 KB |
Output is correct |
68 |
Correct |
34 ms |
1260 KB |
Output is correct |
69 |
Correct |
263 ms |
5344 KB |
Output is correct |
70 |
Correct |
155 ms |
3556 KB |
Output is correct |
71 |
Correct |
150 ms |
3300 KB |
Output is correct |
72 |
Correct |
150 ms |
2412 KB |
Output is correct |
73 |
Correct |
148 ms |
2284 KB |
Output is correct |
74 |
Correct |
269 ms |
5600 KB |
Output is correct |
75 |
Correct |
215 ms |
4448 KB |
Output is correct |
76 |
Correct |
297 ms |
5728 KB |
Output is correct |
77 |
Correct |
294 ms |
5856 KB |
Output is correct |