#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[275][270*270+5];
int arr[275];
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 |
39 ms |
78684 KB |
Output is correct |
2 |
Correct |
40 ms |
78676 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
38 ms |
78684 KB |
Output is correct |
5 |
Correct |
64 ms |
78920 KB |
Output is correct |
6 |
Correct |
45 ms |
78884 KB |
Output is correct |
7 |
Correct |
40 ms |
78672 KB |
Output is correct |
8 |
Correct |
53 ms |
78836 KB |
Output is correct |
9 |
Correct |
50 ms |
78908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
78684 KB |
Output is correct |
2 |
Correct |
40 ms |
78676 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
38 ms |
78684 KB |
Output is correct |
5 |
Correct |
64 ms |
78920 KB |
Output is correct |
6 |
Correct |
45 ms |
78884 KB |
Output is correct |
7 |
Correct |
40 ms |
78672 KB |
Output is correct |
8 |
Correct |
53 ms |
78836 KB |
Output is correct |
9 |
Correct |
50 ms |
78908 KB |
Output is correct |
10 |
Correct |
86 ms |
78676 KB |
Output is correct |
11 |
Correct |
97 ms |
78908 KB |
Output is correct |
12 |
Correct |
90 ms |
78672 KB |
Output is correct |
13 |
Correct |
77 ms |
78676 KB |
Output is correct |
14 |
Correct |
85 ms |
78684 KB |
Output is correct |
15 |
Correct |
79 ms |
78680 KB |
Output is correct |
16 |
Correct |
91 ms |
78672 KB |
Output is correct |
17 |
Correct |
68 ms |
78672 KB |
Output is correct |
18 |
Correct |
71 ms |
78904 KB |
Output is correct |
19 |
Correct |
79 ms |
78672 KB |
Output is correct |
20 |
Correct |
87 ms |
78684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
78684 KB |
Output is correct |
2 |
Correct |
40 ms |
78676 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
38 ms |
78684 KB |
Output is correct |
5 |
Correct |
64 ms |
78920 KB |
Output is correct |
6 |
Correct |
45 ms |
78884 KB |
Output is correct |
7 |
Correct |
40 ms |
78672 KB |
Output is correct |
8 |
Correct |
53 ms |
78836 KB |
Output is correct |
9 |
Correct |
50 ms |
78908 KB |
Output is correct |
10 |
Correct |
86 ms |
78676 KB |
Output is correct |
11 |
Correct |
97 ms |
78908 KB |
Output is correct |
12 |
Correct |
90 ms |
78672 KB |
Output is correct |
13 |
Correct |
77 ms |
78676 KB |
Output is correct |
14 |
Correct |
85 ms |
78684 KB |
Output is correct |
15 |
Correct |
79 ms |
78680 KB |
Output is correct |
16 |
Correct |
91 ms |
78672 KB |
Output is correct |
17 |
Correct |
68 ms |
78672 KB |
Output is correct |
18 |
Correct |
71 ms |
78904 KB |
Output is correct |
19 |
Correct |
79 ms |
78672 KB |
Output is correct |
20 |
Correct |
87 ms |
78684 KB |
Output is correct |
21 |
Correct |
222 ms |
78808 KB |
Output is correct |
22 |
Correct |
277 ms |
78940 KB |
Output is correct |
23 |
Correct |
160 ms |
78936 KB |
Output is correct |
24 |
Correct |
399 ms |
79012 KB |
Output is correct |
25 |
Correct |
500 ms |
78924 KB |
Output is correct |
26 |
Correct |
567 ms |
78940 KB |
Output is correct |
27 |
Correct |
418 ms |
78812 KB |
Output is correct |
28 |
Correct |
363 ms |
79008 KB |
Output is correct |
29 |
Correct |
407 ms |
78932 KB |
Output is correct |
30 |
Correct |
411 ms |
79152 KB |
Output is correct |
31 |
Correct |
501 ms |
78928 KB |
Output is correct |
32 |
Correct |
436 ms |
78932 KB |
Output is correct |
33 |
Correct |
215 ms |
78720 KB |
Output is correct |
34 |
Correct |
229 ms |
78908 KB |
Output is correct |
35 |
Correct |
441 ms |
79076 KB |
Output is correct |
36 |
Correct |
451 ms |
79056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
78684 KB |
Output is correct |
2 |
Correct |
40 ms |
78676 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
38 ms |
78684 KB |
Output is correct |
5 |
Correct |
64 ms |
78920 KB |
Output is correct |
6 |
Correct |
45 ms |
78884 KB |
Output is correct |
7 |
Correct |
40 ms |
78672 KB |
Output is correct |
8 |
Correct |
53 ms |
78836 KB |
Output is correct |
9 |
Correct |
50 ms |
78908 KB |
Output is correct |
10 |
Correct |
86 ms |
78676 KB |
Output is correct |
11 |
Correct |
97 ms |
78908 KB |
Output is correct |
12 |
Correct |
90 ms |
78672 KB |
Output is correct |
13 |
Correct |
77 ms |
78676 KB |
Output is correct |
14 |
Correct |
85 ms |
78684 KB |
Output is correct |
15 |
Correct |
79 ms |
78680 KB |
Output is correct |
16 |
Correct |
91 ms |
78672 KB |
Output is correct |
17 |
Correct |
68 ms |
78672 KB |
Output is correct |
18 |
Correct |
71 ms |
78904 KB |
Output is correct |
19 |
Correct |
79 ms |
78672 KB |
Output is correct |
20 |
Correct |
87 ms |
78684 KB |
Output is correct |
21 |
Correct |
222 ms |
78808 KB |
Output is correct |
22 |
Correct |
277 ms |
78940 KB |
Output is correct |
23 |
Correct |
160 ms |
78936 KB |
Output is correct |
24 |
Correct |
399 ms |
79012 KB |
Output is correct |
25 |
Correct |
500 ms |
78924 KB |
Output is correct |
26 |
Correct |
567 ms |
78940 KB |
Output is correct |
27 |
Correct |
418 ms |
78812 KB |
Output is correct |
28 |
Correct |
363 ms |
79008 KB |
Output is correct |
29 |
Correct |
407 ms |
78932 KB |
Output is correct |
30 |
Correct |
411 ms |
79152 KB |
Output is correct |
31 |
Correct |
501 ms |
78928 KB |
Output is correct |
32 |
Correct |
436 ms |
78932 KB |
Output is correct |
33 |
Correct |
215 ms |
78720 KB |
Output is correct |
34 |
Correct |
229 ms |
78908 KB |
Output is correct |
35 |
Correct |
441 ms |
79076 KB |
Output is correct |
36 |
Correct |
451 ms |
79056 KB |
Output is correct |
37 |
Execution timed out |
1014 ms |
79192 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
78684 KB |
Output is correct |
2 |
Correct |
40 ms |
78676 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
38 ms |
78684 KB |
Output is correct |
5 |
Correct |
64 ms |
78920 KB |
Output is correct |
6 |
Correct |
45 ms |
78884 KB |
Output is correct |
7 |
Correct |
40 ms |
78672 KB |
Output is correct |
8 |
Correct |
53 ms |
78836 KB |
Output is correct |
9 |
Correct |
50 ms |
78908 KB |
Output is correct |
10 |
Correct |
86 ms |
78676 KB |
Output is correct |
11 |
Correct |
97 ms |
78908 KB |
Output is correct |
12 |
Correct |
90 ms |
78672 KB |
Output is correct |
13 |
Correct |
77 ms |
78676 KB |
Output is correct |
14 |
Correct |
85 ms |
78684 KB |
Output is correct |
15 |
Correct |
79 ms |
78680 KB |
Output is correct |
16 |
Correct |
91 ms |
78672 KB |
Output is correct |
17 |
Correct |
68 ms |
78672 KB |
Output is correct |
18 |
Correct |
71 ms |
78904 KB |
Output is correct |
19 |
Correct |
79 ms |
78672 KB |
Output is correct |
20 |
Correct |
87 ms |
78684 KB |
Output is correct |
21 |
Correct |
222 ms |
78808 KB |
Output is correct |
22 |
Correct |
277 ms |
78940 KB |
Output is correct |
23 |
Correct |
160 ms |
78936 KB |
Output is correct |
24 |
Correct |
399 ms |
79012 KB |
Output is correct |
25 |
Correct |
500 ms |
78924 KB |
Output is correct |
26 |
Correct |
567 ms |
78940 KB |
Output is correct |
27 |
Correct |
418 ms |
78812 KB |
Output is correct |
28 |
Correct |
363 ms |
79008 KB |
Output is correct |
29 |
Correct |
407 ms |
78932 KB |
Output is correct |
30 |
Correct |
411 ms |
79152 KB |
Output is correct |
31 |
Correct |
501 ms |
78928 KB |
Output is correct |
32 |
Correct |
436 ms |
78932 KB |
Output is correct |
33 |
Correct |
215 ms |
78720 KB |
Output is correct |
34 |
Correct |
229 ms |
78908 KB |
Output is correct |
35 |
Correct |
441 ms |
79076 KB |
Output is correct |
36 |
Correct |
451 ms |
79056 KB |
Output is correct |
37 |
Execution timed out |
1014 ms |
79192 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
78684 KB |
Output is correct |
2 |
Correct |
40 ms |
78676 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
38 ms |
78684 KB |
Output is correct |
5 |
Correct |
64 ms |
78920 KB |
Output is correct |
6 |
Correct |
45 ms |
78884 KB |
Output is correct |
7 |
Correct |
40 ms |
78672 KB |
Output is correct |
8 |
Correct |
53 ms |
78836 KB |
Output is correct |
9 |
Correct |
50 ms |
78908 KB |
Output is correct |
10 |
Correct |
86 ms |
78676 KB |
Output is correct |
11 |
Correct |
97 ms |
78908 KB |
Output is correct |
12 |
Correct |
90 ms |
78672 KB |
Output is correct |
13 |
Correct |
77 ms |
78676 KB |
Output is correct |
14 |
Correct |
85 ms |
78684 KB |
Output is correct |
15 |
Correct |
79 ms |
78680 KB |
Output is correct |
16 |
Correct |
91 ms |
78672 KB |
Output is correct |
17 |
Correct |
68 ms |
78672 KB |
Output is correct |
18 |
Correct |
71 ms |
78904 KB |
Output is correct |
19 |
Correct |
79 ms |
78672 KB |
Output is correct |
20 |
Correct |
87 ms |
78684 KB |
Output is correct |
21 |
Correct |
222 ms |
78808 KB |
Output is correct |
22 |
Correct |
277 ms |
78940 KB |
Output is correct |
23 |
Correct |
160 ms |
78936 KB |
Output is correct |
24 |
Correct |
399 ms |
79012 KB |
Output is correct |
25 |
Correct |
500 ms |
78924 KB |
Output is correct |
26 |
Correct |
567 ms |
78940 KB |
Output is correct |
27 |
Correct |
418 ms |
78812 KB |
Output is correct |
28 |
Correct |
363 ms |
79008 KB |
Output is correct |
29 |
Correct |
407 ms |
78932 KB |
Output is correct |
30 |
Correct |
411 ms |
79152 KB |
Output is correct |
31 |
Correct |
501 ms |
78928 KB |
Output is correct |
32 |
Correct |
436 ms |
78932 KB |
Output is correct |
33 |
Correct |
215 ms |
78720 KB |
Output is correct |
34 |
Correct |
229 ms |
78908 KB |
Output is correct |
35 |
Correct |
441 ms |
79076 KB |
Output is correct |
36 |
Correct |
451 ms |
79056 KB |
Output is correct |
37 |
Execution timed out |
1014 ms |
79192 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |