/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
int vis[101][10001];
int arr[501],skip=-1,t,flag=0;
int ans[10001],curr[10001];
int n;
void solve(int i,int sum){
if(((t-arr[skip])-sum)-sum<0) return;
if(vis[i][sum]==1) return;
if(i==n){
curr[((t-arr[skip])-sum)-sum]=1;
return;
}
if(i!=skip) solve(i+1,sum+arr[i]);
solve(i+1,sum);
vis[i][sum]=1;
return;
}
void check(int i,int sum){
if(sum>(t+1)/2) return;
if(vis[i][sum]==1) return ;
if(i==n){
if(t/2==sum) flag=1;
return;
}
check(i+1,sum+arr[i]);
check(i+1,sum);
vis[i][sum]=1;
return;
}
signed main()
{
cin>>n;
for(int i=0;i<n;i++){
cin>>arr[i];
t+=arr[i];
}
if(t%2==0) check(0,0);
if(flag==0){
cout<<0<<endl;
return 0;
}
skip=0;
memset(vis,0,sizeof vis);
solve(0,0);
for(int i=1;i<=10000;i++) ans[i]=curr[i];
for(int i=1;i<n;i++){
skip=i;
memset(vis,0,sizeof vis);
memset(curr,0,sizeof curr);
solve(0,0);
for(int j=1;j<=10000;j++) ans[j]=min(ans[j],curr[j]);
for(int j=1;j<=10000;j++) ans[j]=min(ans[j],curr[j]);
}
int siz=0;
for(int j=1;j<=10000;j++) siz+=ans[j];
cout<<siz<<endl;
for(int j=1;j<=10000;j++) if(ans[j]==1) cout<<j<<" ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
3 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4444 KB |
Output is correct |
7 |
Correct |
3 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
3 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4444 KB |
Output is correct |
7 |
Correct |
3 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
6 ms |
4440 KB |
Output is correct |
11 |
Correct |
7 ms |
4444 KB |
Output is correct |
12 |
Correct |
6 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4408 KB |
Output is correct |
14 |
Correct |
5 ms |
4444 KB |
Output is correct |
15 |
Correct |
7 ms |
4468 KB |
Output is correct |
16 |
Correct |
6 ms |
4440 KB |
Output is correct |
17 |
Correct |
3 ms |
4444 KB |
Output is correct |
18 |
Correct |
6 ms |
4444 KB |
Output is correct |
19 |
Correct |
4 ms |
4440 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
3 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4444 KB |
Output is correct |
7 |
Correct |
3 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
6 ms |
4440 KB |
Output is correct |
11 |
Correct |
7 ms |
4444 KB |
Output is correct |
12 |
Correct |
6 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4408 KB |
Output is correct |
14 |
Correct |
5 ms |
4444 KB |
Output is correct |
15 |
Correct |
7 ms |
4468 KB |
Output is correct |
16 |
Correct |
6 ms |
4440 KB |
Output is correct |
17 |
Correct |
3 ms |
4444 KB |
Output is correct |
18 |
Correct |
6 ms |
4444 KB |
Output is correct |
19 |
Correct |
4 ms |
4440 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
21 |
Correct |
46 ms |
4460 KB |
Output is correct |
22 |
Correct |
62 ms |
4444 KB |
Output is correct |
23 |
Correct |
26 ms |
4440 KB |
Output is correct |
24 |
Correct |
120 ms |
4444 KB |
Output is correct |
25 |
Correct |
137 ms |
4444 KB |
Output is correct |
26 |
Correct |
174 ms |
4444 KB |
Output is correct |
27 |
Correct |
111 ms |
4444 KB |
Output is correct |
28 |
Correct |
90 ms |
4440 KB |
Output is correct |
29 |
Correct |
91 ms |
4696 KB |
Output is correct |
30 |
Correct |
180 ms |
4448 KB |
Output is correct |
31 |
Correct |
196 ms |
4440 KB |
Output is correct |
32 |
Correct |
135 ms |
4440 KB |
Output is correct |
33 |
Correct |
14 ms |
4280 KB |
Output is correct |
34 |
Correct |
14 ms |
4444 KB |
Output is correct |
35 |
Correct |
83 ms |
4424 KB |
Output is correct |
36 |
Correct |
144 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
3 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4444 KB |
Output is correct |
7 |
Correct |
3 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
6 ms |
4440 KB |
Output is correct |
11 |
Correct |
7 ms |
4444 KB |
Output is correct |
12 |
Correct |
6 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4408 KB |
Output is correct |
14 |
Correct |
5 ms |
4444 KB |
Output is correct |
15 |
Correct |
7 ms |
4468 KB |
Output is correct |
16 |
Correct |
6 ms |
4440 KB |
Output is correct |
17 |
Correct |
3 ms |
4444 KB |
Output is correct |
18 |
Correct |
6 ms |
4444 KB |
Output is correct |
19 |
Correct |
4 ms |
4440 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
21 |
Correct |
46 ms |
4460 KB |
Output is correct |
22 |
Correct |
62 ms |
4444 KB |
Output is correct |
23 |
Correct |
26 ms |
4440 KB |
Output is correct |
24 |
Correct |
120 ms |
4444 KB |
Output is correct |
25 |
Correct |
137 ms |
4444 KB |
Output is correct |
26 |
Correct |
174 ms |
4444 KB |
Output is correct |
27 |
Correct |
111 ms |
4444 KB |
Output is correct |
28 |
Correct |
90 ms |
4440 KB |
Output is correct |
29 |
Correct |
91 ms |
4696 KB |
Output is correct |
30 |
Correct |
180 ms |
4448 KB |
Output is correct |
31 |
Correct |
196 ms |
4440 KB |
Output is correct |
32 |
Correct |
135 ms |
4440 KB |
Output is correct |
33 |
Correct |
14 ms |
4280 KB |
Output is correct |
34 |
Correct |
14 ms |
4444 KB |
Output is correct |
35 |
Correct |
83 ms |
4424 KB |
Output is correct |
36 |
Correct |
144 ms |
4444 KB |
Output is correct |
37 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
3 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4444 KB |
Output is correct |
7 |
Correct |
3 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
6 ms |
4440 KB |
Output is correct |
11 |
Correct |
7 ms |
4444 KB |
Output is correct |
12 |
Correct |
6 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4408 KB |
Output is correct |
14 |
Correct |
5 ms |
4444 KB |
Output is correct |
15 |
Correct |
7 ms |
4468 KB |
Output is correct |
16 |
Correct |
6 ms |
4440 KB |
Output is correct |
17 |
Correct |
3 ms |
4444 KB |
Output is correct |
18 |
Correct |
6 ms |
4444 KB |
Output is correct |
19 |
Correct |
4 ms |
4440 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
21 |
Correct |
46 ms |
4460 KB |
Output is correct |
22 |
Correct |
62 ms |
4444 KB |
Output is correct |
23 |
Correct |
26 ms |
4440 KB |
Output is correct |
24 |
Correct |
120 ms |
4444 KB |
Output is correct |
25 |
Correct |
137 ms |
4444 KB |
Output is correct |
26 |
Correct |
174 ms |
4444 KB |
Output is correct |
27 |
Correct |
111 ms |
4444 KB |
Output is correct |
28 |
Correct |
90 ms |
4440 KB |
Output is correct |
29 |
Correct |
91 ms |
4696 KB |
Output is correct |
30 |
Correct |
180 ms |
4448 KB |
Output is correct |
31 |
Correct |
196 ms |
4440 KB |
Output is correct |
32 |
Correct |
135 ms |
4440 KB |
Output is correct |
33 |
Correct |
14 ms |
4280 KB |
Output is correct |
34 |
Correct |
14 ms |
4444 KB |
Output is correct |
35 |
Correct |
83 ms |
4424 KB |
Output is correct |
36 |
Correct |
144 ms |
4444 KB |
Output is correct |
37 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
3 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4444 KB |
Output is correct |
7 |
Correct |
3 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
6 ms |
4440 KB |
Output is correct |
11 |
Correct |
7 ms |
4444 KB |
Output is correct |
12 |
Correct |
6 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4408 KB |
Output is correct |
14 |
Correct |
5 ms |
4444 KB |
Output is correct |
15 |
Correct |
7 ms |
4468 KB |
Output is correct |
16 |
Correct |
6 ms |
4440 KB |
Output is correct |
17 |
Correct |
3 ms |
4444 KB |
Output is correct |
18 |
Correct |
6 ms |
4444 KB |
Output is correct |
19 |
Correct |
4 ms |
4440 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
21 |
Correct |
46 ms |
4460 KB |
Output is correct |
22 |
Correct |
62 ms |
4444 KB |
Output is correct |
23 |
Correct |
26 ms |
4440 KB |
Output is correct |
24 |
Correct |
120 ms |
4444 KB |
Output is correct |
25 |
Correct |
137 ms |
4444 KB |
Output is correct |
26 |
Correct |
174 ms |
4444 KB |
Output is correct |
27 |
Correct |
111 ms |
4444 KB |
Output is correct |
28 |
Correct |
90 ms |
4440 KB |
Output is correct |
29 |
Correct |
91 ms |
4696 KB |
Output is correct |
30 |
Correct |
180 ms |
4448 KB |
Output is correct |
31 |
Correct |
196 ms |
4440 KB |
Output is correct |
32 |
Correct |
135 ms |
4440 KB |
Output is correct |
33 |
Correct |
14 ms |
4280 KB |
Output is correct |
34 |
Correct |
14 ms |
4444 KB |
Output is correct |
35 |
Correct |
83 ms |
4424 KB |
Output is correct |
36 |
Correct |
144 ms |
4444 KB |
Output is correct |
37 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
38 |
Halted |
0 ms |
0 KB |
- |