#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int 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;
for(auto &x:vec)cin>>x;
for(int i=0;i<n;i++){
for(int j=1;j<=1e6;j++){
bool check=1;
for(int k=0;k<n;k++){
int l=vec[k];
vec[k]=j;
//cout<<l<<" ";
int 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<<" ";
}
int 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 |
128 ms |
348 KB |
Output is correct |
2 |
Correct |
811 ms |
424 KB |
Output is correct |
3 |
Incorrect |
47 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
348 KB |
Output is correct |
2 |
Correct |
811 ms |
424 KB |
Output is correct |
3 |
Incorrect |
47 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
348 KB |
Output is correct |
2 |
Correct |
811 ms |
424 KB |
Output is correct |
3 |
Incorrect |
47 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
348 KB |
Output is correct |
2 |
Correct |
811 ms |
424 KB |
Output is correct |
3 |
Incorrect |
47 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
348 KB |
Output is correct |
2 |
Correct |
811 ms |
424 KB |
Output is correct |
3 |
Incorrect |
47 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
348 KB |
Output is correct |
2 |
Correct |
811 ms |
424 KB |
Output is correct |
3 |
Incorrect |
47 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |