#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(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 |
4440 KB |
Output is correct |
2 |
Runtime error |
5 ms |
8540 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Runtime error |
5 ms |
8540 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Runtime error |
5 ms |
8540 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Runtime error |
5 ms |
8540 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Runtime error |
5 ms |
8540 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Runtime error |
5 ms |
8540 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |