#include <bits/stdc++.h>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
int vis[105][10005];
int arr[105];
ll skipped;
int ans=0;
int n,wholesum=0;
map<int,int>mp;
ll sum=0;
void rec(int x){
if(vis[x][sum]||ans) return;
if(skipped==x){
rec(x+1);
return;
}
if(x==n+1){
if(sum==wholesum-sum) ans=1;
return;
}
vis[x][sum]=1;
if(x==n){
ll k=wholesum-sum;
mp[abs(sum-k)]++;
return;
}
sum+=arr[x];
rec(x+1);
sum-=arr[x];
rec(x+1);
}
void solve(){
cin>>n;
for(int i=0;i<n;i++){
cin>>arr[i];
wholesum+=arr[i];
}
skipped=n;
rec(0);
if(ans==0){
co 0;
return;
}
ans=0;
vector<int>answers;
for(int i=0;i<n;i++){
memset(vis,0,sizeof(vis));
wholesum-=arr[i];
skipped=i;
rec(0);
wholesum+=arr[i];
}
for(auto i:mp){
if(i.first<1) continue;
if(i.second/2==n) answers.push_back(i.first);
}
co answers.size()<<'\n';
for(auto i:answers) co i<<' ';
}
int main()
{
suiii
int t=1;
// cin>>t;
while(t--){
solve();
}
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 |
4 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4588 KB |
Output is correct |
9 |
Correct |
3 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 |
4 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4588 KB |
Output is correct |
9 |
Correct |
3 ms |
4444 KB |
Output is correct |
10 |
Correct |
4 ms |
4440 KB |
Output is correct |
11 |
Correct |
6 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4444 KB |
Output is correct |
14 |
Correct |
6 ms |
4444 KB |
Output is correct |
15 |
Correct |
5 ms |
4568 KB |
Output is correct |
16 |
Correct |
6 ms |
4444 KB |
Output is correct |
17 |
Correct |
4 ms |
4572 KB |
Output is correct |
18 |
Correct |
4 ms |
4444 KB |
Output is correct |
19 |
Correct |
6 ms |
4508 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 |
4 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4588 KB |
Output is correct |
9 |
Correct |
3 ms |
4444 KB |
Output is correct |
10 |
Correct |
4 ms |
4440 KB |
Output is correct |
11 |
Correct |
6 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4444 KB |
Output is correct |
14 |
Correct |
6 ms |
4444 KB |
Output is correct |
15 |
Correct |
5 ms |
4568 KB |
Output is correct |
16 |
Correct |
6 ms |
4444 KB |
Output is correct |
17 |
Correct |
4 ms |
4572 KB |
Output is correct |
18 |
Correct |
4 ms |
4444 KB |
Output is correct |
19 |
Correct |
6 ms |
4508 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
21 |
Correct |
63 ms |
4444 KB |
Output is correct |
22 |
Correct |
83 ms |
4444 KB |
Output is correct |
23 |
Correct |
35 ms |
4444 KB |
Output is correct |
24 |
Correct |
158 ms |
4688 KB |
Output is correct |
25 |
Correct |
180 ms |
4740 KB |
Output is correct |
26 |
Correct |
216 ms |
4696 KB |
Output is correct |
27 |
Correct |
135 ms |
4444 KB |
Output is correct |
28 |
Correct |
100 ms |
4660 KB |
Output is correct |
29 |
Correct |
114 ms |
4732 KB |
Output is correct |
30 |
Correct |
177 ms |
4696 KB |
Output is correct |
31 |
Correct |
249 ms |
4716 KB |
Output is correct |
32 |
Correct |
162 ms |
4688 KB |
Output is correct |
33 |
Correct |
13 ms |
4440 KB |
Output is correct |
34 |
Correct |
12 ms |
4536 KB |
Output is correct |
35 |
Correct |
109 ms |
4952 KB |
Output is correct |
36 |
Correct |
174 ms |
4688 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 |
4 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4588 KB |
Output is correct |
9 |
Correct |
3 ms |
4444 KB |
Output is correct |
10 |
Correct |
4 ms |
4440 KB |
Output is correct |
11 |
Correct |
6 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4444 KB |
Output is correct |
14 |
Correct |
6 ms |
4444 KB |
Output is correct |
15 |
Correct |
5 ms |
4568 KB |
Output is correct |
16 |
Correct |
6 ms |
4444 KB |
Output is correct |
17 |
Correct |
4 ms |
4572 KB |
Output is correct |
18 |
Correct |
4 ms |
4444 KB |
Output is correct |
19 |
Correct |
6 ms |
4508 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
21 |
Correct |
63 ms |
4444 KB |
Output is correct |
22 |
Correct |
83 ms |
4444 KB |
Output is correct |
23 |
Correct |
35 ms |
4444 KB |
Output is correct |
24 |
Correct |
158 ms |
4688 KB |
Output is correct |
25 |
Correct |
180 ms |
4740 KB |
Output is correct |
26 |
Correct |
216 ms |
4696 KB |
Output is correct |
27 |
Correct |
135 ms |
4444 KB |
Output is correct |
28 |
Correct |
100 ms |
4660 KB |
Output is correct |
29 |
Correct |
114 ms |
4732 KB |
Output is correct |
30 |
Correct |
177 ms |
4696 KB |
Output is correct |
31 |
Correct |
249 ms |
4716 KB |
Output is correct |
32 |
Correct |
162 ms |
4688 KB |
Output is correct |
33 |
Correct |
13 ms |
4440 KB |
Output is correct |
34 |
Correct |
12 ms |
4536 KB |
Output is correct |
35 |
Correct |
109 ms |
4952 KB |
Output is correct |
36 |
Correct |
174 ms |
4688 KB |
Output is correct |
37 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
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 |
4 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4588 KB |
Output is correct |
9 |
Correct |
3 ms |
4444 KB |
Output is correct |
10 |
Correct |
4 ms |
4440 KB |
Output is correct |
11 |
Correct |
6 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4444 KB |
Output is correct |
14 |
Correct |
6 ms |
4444 KB |
Output is correct |
15 |
Correct |
5 ms |
4568 KB |
Output is correct |
16 |
Correct |
6 ms |
4444 KB |
Output is correct |
17 |
Correct |
4 ms |
4572 KB |
Output is correct |
18 |
Correct |
4 ms |
4444 KB |
Output is correct |
19 |
Correct |
6 ms |
4508 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
21 |
Correct |
63 ms |
4444 KB |
Output is correct |
22 |
Correct |
83 ms |
4444 KB |
Output is correct |
23 |
Correct |
35 ms |
4444 KB |
Output is correct |
24 |
Correct |
158 ms |
4688 KB |
Output is correct |
25 |
Correct |
180 ms |
4740 KB |
Output is correct |
26 |
Correct |
216 ms |
4696 KB |
Output is correct |
27 |
Correct |
135 ms |
4444 KB |
Output is correct |
28 |
Correct |
100 ms |
4660 KB |
Output is correct |
29 |
Correct |
114 ms |
4732 KB |
Output is correct |
30 |
Correct |
177 ms |
4696 KB |
Output is correct |
31 |
Correct |
249 ms |
4716 KB |
Output is correct |
32 |
Correct |
162 ms |
4688 KB |
Output is correct |
33 |
Correct |
13 ms |
4440 KB |
Output is correct |
34 |
Correct |
12 ms |
4536 KB |
Output is correct |
35 |
Correct |
109 ms |
4952 KB |
Output is correct |
36 |
Correct |
174 ms |
4688 KB |
Output is correct |
37 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
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 |
4 ms |
4588 KB |
Output is correct |
6 |
Correct |
3 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
3 ms |
4588 KB |
Output is correct |
9 |
Correct |
3 ms |
4444 KB |
Output is correct |
10 |
Correct |
4 ms |
4440 KB |
Output is correct |
11 |
Correct |
6 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
4444 KB |
Output is correct |
13 |
Correct |
6 ms |
4444 KB |
Output is correct |
14 |
Correct |
6 ms |
4444 KB |
Output is correct |
15 |
Correct |
5 ms |
4568 KB |
Output is correct |
16 |
Correct |
6 ms |
4444 KB |
Output is correct |
17 |
Correct |
4 ms |
4572 KB |
Output is correct |
18 |
Correct |
4 ms |
4444 KB |
Output is correct |
19 |
Correct |
6 ms |
4508 KB |
Output is correct |
20 |
Correct |
5 ms |
4444 KB |
Output is correct |
21 |
Correct |
63 ms |
4444 KB |
Output is correct |
22 |
Correct |
83 ms |
4444 KB |
Output is correct |
23 |
Correct |
35 ms |
4444 KB |
Output is correct |
24 |
Correct |
158 ms |
4688 KB |
Output is correct |
25 |
Correct |
180 ms |
4740 KB |
Output is correct |
26 |
Correct |
216 ms |
4696 KB |
Output is correct |
27 |
Correct |
135 ms |
4444 KB |
Output is correct |
28 |
Correct |
100 ms |
4660 KB |
Output is correct |
29 |
Correct |
114 ms |
4732 KB |
Output is correct |
30 |
Correct |
177 ms |
4696 KB |
Output is correct |
31 |
Correct |
249 ms |
4716 KB |
Output is correct |
32 |
Correct |
162 ms |
4688 KB |
Output is correct |
33 |
Correct |
13 ms |
4440 KB |
Output is correct |
34 |
Correct |
12 ms |
4536 KB |
Output is correct |
35 |
Correct |
109 ms |
4952 KB |
Output is correct |
36 |
Correct |
174 ms |
4688 KB |
Output is correct |
37 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |