#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];
int skipped;
int ans=0;
int n,wholesum=0;
int mp[275*275+5];
int 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(int i=1;i<=275*275;i++){
if(mp[i]/2==n) answers.push_back(i);
}
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 |
26 ms |
78928 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
30 ms |
78824 KB |
Output is correct |
5 |
Correct |
44 ms |
79192 KB |
Output is correct |
6 |
Correct |
36 ms |
78936 KB |
Output is correct |
7 |
Correct |
31 ms |
79192 KB |
Output is correct |
8 |
Correct |
43 ms |
78840 KB |
Output is correct |
9 |
Correct |
36 ms |
78940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
78928 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
30 ms |
78824 KB |
Output is correct |
5 |
Correct |
44 ms |
79192 KB |
Output is correct |
6 |
Correct |
36 ms |
78936 KB |
Output is correct |
7 |
Correct |
31 ms |
79192 KB |
Output is correct |
8 |
Correct |
43 ms |
78840 KB |
Output is correct |
9 |
Correct |
36 ms |
78940 KB |
Output is correct |
10 |
Correct |
78 ms |
79020 KB |
Output is correct |
11 |
Correct |
83 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
79024 KB |
Output is correct |
13 |
Correct |
66 ms |
78936 KB |
Output is correct |
14 |
Correct |
76 ms |
78940 KB |
Output is correct |
15 |
Correct |
71 ms |
78940 KB |
Output is correct |
16 |
Correct |
86 ms |
79020 KB |
Output is correct |
17 |
Correct |
48 ms |
79020 KB |
Output is correct |
18 |
Correct |
61 ms |
78928 KB |
Output is correct |
19 |
Correct |
71 ms |
78852 KB |
Output is correct |
20 |
Correct |
77 ms |
78940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
78928 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
30 ms |
78824 KB |
Output is correct |
5 |
Correct |
44 ms |
79192 KB |
Output is correct |
6 |
Correct |
36 ms |
78936 KB |
Output is correct |
7 |
Correct |
31 ms |
79192 KB |
Output is correct |
8 |
Correct |
43 ms |
78840 KB |
Output is correct |
9 |
Correct |
36 ms |
78940 KB |
Output is correct |
10 |
Correct |
78 ms |
79020 KB |
Output is correct |
11 |
Correct |
83 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
79024 KB |
Output is correct |
13 |
Correct |
66 ms |
78936 KB |
Output is correct |
14 |
Correct |
76 ms |
78940 KB |
Output is correct |
15 |
Correct |
71 ms |
78940 KB |
Output is correct |
16 |
Correct |
86 ms |
79020 KB |
Output is correct |
17 |
Correct |
48 ms |
79020 KB |
Output is correct |
18 |
Correct |
61 ms |
78928 KB |
Output is correct |
19 |
Correct |
71 ms |
78852 KB |
Output is correct |
20 |
Correct |
77 ms |
78940 KB |
Output is correct |
21 |
Correct |
198 ms |
79048 KB |
Output is correct |
22 |
Correct |
251 ms |
79032 KB |
Output is correct |
23 |
Correct |
140 ms |
79036 KB |
Output is correct |
24 |
Correct |
373 ms |
78936 KB |
Output is correct |
25 |
Correct |
412 ms |
78936 KB |
Output is correct |
26 |
Correct |
465 ms |
78940 KB |
Output is correct |
27 |
Correct |
378 ms |
79048 KB |
Output is correct |
28 |
Correct |
357 ms |
78928 KB |
Output is correct |
29 |
Correct |
390 ms |
78936 KB |
Output is correct |
30 |
Correct |
438 ms |
79032 KB |
Output is correct |
31 |
Correct |
468 ms |
79068 KB |
Output is correct |
32 |
Correct |
406 ms |
78940 KB |
Output is correct |
33 |
Correct |
201 ms |
78936 KB |
Output is correct |
34 |
Correct |
202 ms |
79056 KB |
Output is correct |
35 |
Correct |
363 ms |
78928 KB |
Output is correct |
36 |
Correct |
382 ms |
78940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
78928 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
30 ms |
78824 KB |
Output is correct |
5 |
Correct |
44 ms |
79192 KB |
Output is correct |
6 |
Correct |
36 ms |
78936 KB |
Output is correct |
7 |
Correct |
31 ms |
79192 KB |
Output is correct |
8 |
Correct |
43 ms |
78840 KB |
Output is correct |
9 |
Correct |
36 ms |
78940 KB |
Output is correct |
10 |
Correct |
78 ms |
79020 KB |
Output is correct |
11 |
Correct |
83 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
79024 KB |
Output is correct |
13 |
Correct |
66 ms |
78936 KB |
Output is correct |
14 |
Correct |
76 ms |
78940 KB |
Output is correct |
15 |
Correct |
71 ms |
78940 KB |
Output is correct |
16 |
Correct |
86 ms |
79020 KB |
Output is correct |
17 |
Correct |
48 ms |
79020 KB |
Output is correct |
18 |
Correct |
61 ms |
78928 KB |
Output is correct |
19 |
Correct |
71 ms |
78852 KB |
Output is correct |
20 |
Correct |
77 ms |
78940 KB |
Output is correct |
21 |
Correct |
198 ms |
79048 KB |
Output is correct |
22 |
Correct |
251 ms |
79032 KB |
Output is correct |
23 |
Correct |
140 ms |
79036 KB |
Output is correct |
24 |
Correct |
373 ms |
78936 KB |
Output is correct |
25 |
Correct |
412 ms |
78936 KB |
Output is correct |
26 |
Correct |
465 ms |
78940 KB |
Output is correct |
27 |
Correct |
378 ms |
79048 KB |
Output is correct |
28 |
Correct |
357 ms |
78928 KB |
Output is correct |
29 |
Correct |
390 ms |
78936 KB |
Output is correct |
30 |
Correct |
438 ms |
79032 KB |
Output is correct |
31 |
Correct |
468 ms |
79068 KB |
Output is correct |
32 |
Correct |
406 ms |
78940 KB |
Output is correct |
33 |
Correct |
201 ms |
78936 KB |
Output is correct |
34 |
Correct |
202 ms |
79056 KB |
Output is correct |
35 |
Correct |
363 ms |
78928 KB |
Output is correct |
36 |
Correct |
382 ms |
78940 KB |
Output is correct |
37 |
Execution timed out |
1068 ms |
78932 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
78928 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
30 ms |
78824 KB |
Output is correct |
5 |
Correct |
44 ms |
79192 KB |
Output is correct |
6 |
Correct |
36 ms |
78936 KB |
Output is correct |
7 |
Correct |
31 ms |
79192 KB |
Output is correct |
8 |
Correct |
43 ms |
78840 KB |
Output is correct |
9 |
Correct |
36 ms |
78940 KB |
Output is correct |
10 |
Correct |
78 ms |
79020 KB |
Output is correct |
11 |
Correct |
83 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
79024 KB |
Output is correct |
13 |
Correct |
66 ms |
78936 KB |
Output is correct |
14 |
Correct |
76 ms |
78940 KB |
Output is correct |
15 |
Correct |
71 ms |
78940 KB |
Output is correct |
16 |
Correct |
86 ms |
79020 KB |
Output is correct |
17 |
Correct |
48 ms |
79020 KB |
Output is correct |
18 |
Correct |
61 ms |
78928 KB |
Output is correct |
19 |
Correct |
71 ms |
78852 KB |
Output is correct |
20 |
Correct |
77 ms |
78940 KB |
Output is correct |
21 |
Correct |
198 ms |
79048 KB |
Output is correct |
22 |
Correct |
251 ms |
79032 KB |
Output is correct |
23 |
Correct |
140 ms |
79036 KB |
Output is correct |
24 |
Correct |
373 ms |
78936 KB |
Output is correct |
25 |
Correct |
412 ms |
78936 KB |
Output is correct |
26 |
Correct |
465 ms |
78940 KB |
Output is correct |
27 |
Correct |
378 ms |
79048 KB |
Output is correct |
28 |
Correct |
357 ms |
78928 KB |
Output is correct |
29 |
Correct |
390 ms |
78936 KB |
Output is correct |
30 |
Correct |
438 ms |
79032 KB |
Output is correct |
31 |
Correct |
468 ms |
79068 KB |
Output is correct |
32 |
Correct |
406 ms |
78940 KB |
Output is correct |
33 |
Correct |
201 ms |
78936 KB |
Output is correct |
34 |
Correct |
202 ms |
79056 KB |
Output is correct |
35 |
Correct |
363 ms |
78928 KB |
Output is correct |
36 |
Correct |
382 ms |
78940 KB |
Output is correct |
37 |
Execution timed out |
1068 ms |
78932 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
78928 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
30 ms |
78824 KB |
Output is correct |
5 |
Correct |
44 ms |
79192 KB |
Output is correct |
6 |
Correct |
36 ms |
78936 KB |
Output is correct |
7 |
Correct |
31 ms |
79192 KB |
Output is correct |
8 |
Correct |
43 ms |
78840 KB |
Output is correct |
9 |
Correct |
36 ms |
78940 KB |
Output is correct |
10 |
Correct |
78 ms |
79020 KB |
Output is correct |
11 |
Correct |
83 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
79024 KB |
Output is correct |
13 |
Correct |
66 ms |
78936 KB |
Output is correct |
14 |
Correct |
76 ms |
78940 KB |
Output is correct |
15 |
Correct |
71 ms |
78940 KB |
Output is correct |
16 |
Correct |
86 ms |
79020 KB |
Output is correct |
17 |
Correct |
48 ms |
79020 KB |
Output is correct |
18 |
Correct |
61 ms |
78928 KB |
Output is correct |
19 |
Correct |
71 ms |
78852 KB |
Output is correct |
20 |
Correct |
77 ms |
78940 KB |
Output is correct |
21 |
Correct |
198 ms |
79048 KB |
Output is correct |
22 |
Correct |
251 ms |
79032 KB |
Output is correct |
23 |
Correct |
140 ms |
79036 KB |
Output is correct |
24 |
Correct |
373 ms |
78936 KB |
Output is correct |
25 |
Correct |
412 ms |
78936 KB |
Output is correct |
26 |
Correct |
465 ms |
78940 KB |
Output is correct |
27 |
Correct |
378 ms |
79048 KB |
Output is correct |
28 |
Correct |
357 ms |
78928 KB |
Output is correct |
29 |
Correct |
390 ms |
78936 KB |
Output is correct |
30 |
Correct |
438 ms |
79032 KB |
Output is correct |
31 |
Correct |
468 ms |
79068 KB |
Output is correct |
32 |
Correct |
406 ms |
78940 KB |
Output is correct |
33 |
Correct |
201 ms |
78936 KB |
Output is correct |
34 |
Correct |
202 ms |
79056 KB |
Output is correct |
35 |
Correct |
363 ms |
78928 KB |
Output is correct |
36 |
Correct |
382 ms |
78940 KB |
Output is correct |
37 |
Execution timed out |
1068 ms |
78932 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |