#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll rec(int n,vector<int>&vec,int sum1,int sum2){
if(n==0){
return abs(sum1-sum2);
}
int a=rec(n-1,vec,sum1+vec[n-1],sum2);
int b=rec(n-1,vec,sum1,sum2+vec[n-1]);
return min(a,b);
}
void solve(){
int n;cin>>n;
vector<int>vec(n);
set<int>st;
sort(vec.begin(),vec.end());
if(n%2&&vec[0]==vec[vec.size()-1]){
cout<<0;
return;
}
for(auto &x:vec)cin>>x;
for(ll i=0;i<n;i++){
for(ll j=1;j<=1e4;j++){
bool check=1;
for(ll k=0;k<n;k++){
ll l=vec[k];
vec[k]=j;
//cout<<l<<" ";
ll ans=rec(n,vec,0,0);
vec[k]=l;
if(ans!=0){
check=0;
break;
}
}
if(check){
//cout<<j<<" ";
st.insert(j);
}
}
}
cout<<st.size()<<endl;
for(auto &x:st)cout<<x<<" ";
}
signed main() {
cin.tie(0)->sync_with_stdio(false);
#ifdef prince
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int q = 1;
// cin >> q;
while (q--) {
solve();
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Execution timed out |
1044 ms |
344 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Execution timed out |
1044 ms |
344 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Execution timed out |
1044 ms |
344 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Execution timed out |
1044 ms |
344 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Execution timed out |
1044 ms |
344 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Execution timed out |
1044 ms |
344 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |