#include <bits/stdc++.h>
using namespace std;
int a[501], f[250001], ans[250001], Ans, t;
int main(){
int n, s = 0; cin >> n;
f[0] = 1;
ans[0] = n + 1;
for(int i = 1; i <= n; i ++){
cin >> a[i];
for(int j = s; j >= 0; j --)
f[j + a[i]] += f[j];
s += a[i];
}
for(int i = 1; i <= n; i ++){
s -= a[i];
for(int j = 0; j <= s; j ++){
f[j + a[i]] -= f[j];
ans[max(j + j - s, 0)] += (!!f[j]);
Ans += (ans[max(j + j - s, 0)] == n);
}
for(int j = s; j >= 0; j --){
f[j + a[i]] += f[j];
s += a[i];
}
}
if(s & 1 || !f[s / 2]){
cout << 0; return 0;
}
cout << Ans << '\n';
for(int i = 1; i <= s; i ++)
if(ans[i] == n)
cout << i << " ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |