#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],arr[275],skipped,ans=0,n,wholesum=0,mp[275*275+5],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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
78940 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
29 ms |
78876 KB |
Output is correct |
5 |
Correct |
44 ms |
78936 KB |
Output is correct |
6 |
Correct |
34 ms |
78940 KB |
Output is correct |
7 |
Correct |
33 ms |
79000 KB |
Output is correct |
8 |
Correct |
43 ms |
78940 KB |
Output is correct |
9 |
Correct |
41 ms |
78928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
78940 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
29 ms |
78876 KB |
Output is correct |
5 |
Correct |
44 ms |
78936 KB |
Output is correct |
6 |
Correct |
34 ms |
78940 KB |
Output is correct |
7 |
Correct |
33 ms |
79000 KB |
Output is correct |
8 |
Correct |
43 ms |
78940 KB |
Output is correct |
9 |
Correct |
41 ms |
78928 KB |
Output is correct |
10 |
Correct |
81 ms |
79016 KB |
Output is correct |
11 |
Correct |
73 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
78940 KB |
Output is correct |
13 |
Correct |
65 ms |
78936 KB |
Output is correct |
14 |
Correct |
67 ms |
78940 KB |
Output is correct |
15 |
Correct |
65 ms |
78940 KB |
Output is correct |
16 |
Correct |
71 ms |
78940 KB |
Output is correct |
17 |
Correct |
46 ms |
78936 KB |
Output is correct |
18 |
Correct |
59 ms |
78936 KB |
Output is correct |
19 |
Correct |
63 ms |
78936 KB |
Output is correct |
20 |
Correct |
73 ms |
78940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
78940 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
29 ms |
78876 KB |
Output is correct |
5 |
Correct |
44 ms |
78936 KB |
Output is correct |
6 |
Correct |
34 ms |
78940 KB |
Output is correct |
7 |
Correct |
33 ms |
79000 KB |
Output is correct |
8 |
Correct |
43 ms |
78940 KB |
Output is correct |
9 |
Correct |
41 ms |
78928 KB |
Output is correct |
10 |
Correct |
81 ms |
79016 KB |
Output is correct |
11 |
Correct |
73 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
78940 KB |
Output is correct |
13 |
Correct |
65 ms |
78936 KB |
Output is correct |
14 |
Correct |
67 ms |
78940 KB |
Output is correct |
15 |
Correct |
65 ms |
78940 KB |
Output is correct |
16 |
Correct |
71 ms |
78940 KB |
Output is correct |
17 |
Correct |
46 ms |
78936 KB |
Output is correct |
18 |
Correct |
59 ms |
78936 KB |
Output is correct |
19 |
Correct |
63 ms |
78936 KB |
Output is correct |
20 |
Correct |
73 ms |
78940 KB |
Output is correct |
21 |
Correct |
184 ms |
79036 KB |
Output is correct |
22 |
Correct |
256 ms |
78936 KB |
Output is correct |
23 |
Correct |
135 ms |
78940 KB |
Output is correct |
24 |
Correct |
375 ms |
78928 KB |
Output is correct |
25 |
Correct |
413 ms |
78936 KB |
Output is correct |
26 |
Correct |
476 ms |
79052 KB |
Output is correct |
27 |
Correct |
370 ms |
78936 KB |
Output is correct |
28 |
Correct |
334 ms |
78936 KB |
Output is correct |
29 |
Correct |
380 ms |
78928 KB |
Output is correct |
30 |
Correct |
401 ms |
78928 KB |
Output is correct |
31 |
Correct |
479 ms |
79048 KB |
Output is correct |
32 |
Correct |
375 ms |
78936 KB |
Output is correct |
33 |
Correct |
228 ms |
78928 KB |
Output is correct |
34 |
Correct |
200 ms |
78936 KB |
Output is correct |
35 |
Correct |
367 ms |
78936 KB |
Output is correct |
36 |
Correct |
384 ms |
79036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
78940 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
29 ms |
78876 KB |
Output is correct |
5 |
Correct |
44 ms |
78936 KB |
Output is correct |
6 |
Correct |
34 ms |
78940 KB |
Output is correct |
7 |
Correct |
33 ms |
79000 KB |
Output is correct |
8 |
Correct |
43 ms |
78940 KB |
Output is correct |
9 |
Correct |
41 ms |
78928 KB |
Output is correct |
10 |
Correct |
81 ms |
79016 KB |
Output is correct |
11 |
Correct |
73 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
78940 KB |
Output is correct |
13 |
Correct |
65 ms |
78936 KB |
Output is correct |
14 |
Correct |
67 ms |
78940 KB |
Output is correct |
15 |
Correct |
65 ms |
78940 KB |
Output is correct |
16 |
Correct |
71 ms |
78940 KB |
Output is correct |
17 |
Correct |
46 ms |
78936 KB |
Output is correct |
18 |
Correct |
59 ms |
78936 KB |
Output is correct |
19 |
Correct |
63 ms |
78936 KB |
Output is correct |
20 |
Correct |
73 ms |
78940 KB |
Output is correct |
21 |
Correct |
184 ms |
79036 KB |
Output is correct |
22 |
Correct |
256 ms |
78936 KB |
Output is correct |
23 |
Correct |
135 ms |
78940 KB |
Output is correct |
24 |
Correct |
375 ms |
78928 KB |
Output is correct |
25 |
Correct |
413 ms |
78936 KB |
Output is correct |
26 |
Correct |
476 ms |
79052 KB |
Output is correct |
27 |
Correct |
370 ms |
78936 KB |
Output is correct |
28 |
Correct |
334 ms |
78936 KB |
Output is correct |
29 |
Correct |
380 ms |
78928 KB |
Output is correct |
30 |
Correct |
401 ms |
78928 KB |
Output is correct |
31 |
Correct |
479 ms |
79048 KB |
Output is correct |
32 |
Correct |
375 ms |
78936 KB |
Output is correct |
33 |
Correct |
228 ms |
78928 KB |
Output is correct |
34 |
Correct |
200 ms |
78936 KB |
Output is correct |
35 |
Correct |
367 ms |
78936 KB |
Output is correct |
36 |
Correct |
384 ms |
79036 KB |
Output is correct |
37 |
Execution timed out |
1020 ms |
78928 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
78940 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
29 ms |
78876 KB |
Output is correct |
5 |
Correct |
44 ms |
78936 KB |
Output is correct |
6 |
Correct |
34 ms |
78940 KB |
Output is correct |
7 |
Correct |
33 ms |
79000 KB |
Output is correct |
8 |
Correct |
43 ms |
78940 KB |
Output is correct |
9 |
Correct |
41 ms |
78928 KB |
Output is correct |
10 |
Correct |
81 ms |
79016 KB |
Output is correct |
11 |
Correct |
73 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
78940 KB |
Output is correct |
13 |
Correct |
65 ms |
78936 KB |
Output is correct |
14 |
Correct |
67 ms |
78940 KB |
Output is correct |
15 |
Correct |
65 ms |
78940 KB |
Output is correct |
16 |
Correct |
71 ms |
78940 KB |
Output is correct |
17 |
Correct |
46 ms |
78936 KB |
Output is correct |
18 |
Correct |
59 ms |
78936 KB |
Output is correct |
19 |
Correct |
63 ms |
78936 KB |
Output is correct |
20 |
Correct |
73 ms |
78940 KB |
Output is correct |
21 |
Correct |
184 ms |
79036 KB |
Output is correct |
22 |
Correct |
256 ms |
78936 KB |
Output is correct |
23 |
Correct |
135 ms |
78940 KB |
Output is correct |
24 |
Correct |
375 ms |
78928 KB |
Output is correct |
25 |
Correct |
413 ms |
78936 KB |
Output is correct |
26 |
Correct |
476 ms |
79052 KB |
Output is correct |
27 |
Correct |
370 ms |
78936 KB |
Output is correct |
28 |
Correct |
334 ms |
78936 KB |
Output is correct |
29 |
Correct |
380 ms |
78928 KB |
Output is correct |
30 |
Correct |
401 ms |
78928 KB |
Output is correct |
31 |
Correct |
479 ms |
79048 KB |
Output is correct |
32 |
Correct |
375 ms |
78936 KB |
Output is correct |
33 |
Correct |
228 ms |
78928 KB |
Output is correct |
34 |
Correct |
200 ms |
78936 KB |
Output is correct |
35 |
Correct |
367 ms |
78936 KB |
Output is correct |
36 |
Correct |
384 ms |
79036 KB |
Output is correct |
37 |
Execution timed out |
1020 ms |
78928 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
78940 KB |
Output is correct |
2 |
Correct |
29 ms |
78940 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
29 ms |
78876 KB |
Output is correct |
5 |
Correct |
44 ms |
78936 KB |
Output is correct |
6 |
Correct |
34 ms |
78940 KB |
Output is correct |
7 |
Correct |
33 ms |
79000 KB |
Output is correct |
8 |
Correct |
43 ms |
78940 KB |
Output is correct |
9 |
Correct |
41 ms |
78928 KB |
Output is correct |
10 |
Correct |
81 ms |
79016 KB |
Output is correct |
11 |
Correct |
73 ms |
78940 KB |
Output is correct |
12 |
Correct |
76 ms |
78940 KB |
Output is correct |
13 |
Correct |
65 ms |
78936 KB |
Output is correct |
14 |
Correct |
67 ms |
78940 KB |
Output is correct |
15 |
Correct |
65 ms |
78940 KB |
Output is correct |
16 |
Correct |
71 ms |
78940 KB |
Output is correct |
17 |
Correct |
46 ms |
78936 KB |
Output is correct |
18 |
Correct |
59 ms |
78936 KB |
Output is correct |
19 |
Correct |
63 ms |
78936 KB |
Output is correct |
20 |
Correct |
73 ms |
78940 KB |
Output is correct |
21 |
Correct |
184 ms |
79036 KB |
Output is correct |
22 |
Correct |
256 ms |
78936 KB |
Output is correct |
23 |
Correct |
135 ms |
78940 KB |
Output is correct |
24 |
Correct |
375 ms |
78928 KB |
Output is correct |
25 |
Correct |
413 ms |
78936 KB |
Output is correct |
26 |
Correct |
476 ms |
79052 KB |
Output is correct |
27 |
Correct |
370 ms |
78936 KB |
Output is correct |
28 |
Correct |
334 ms |
78936 KB |
Output is correct |
29 |
Correct |
380 ms |
78928 KB |
Output is correct |
30 |
Correct |
401 ms |
78928 KB |
Output is correct |
31 |
Correct |
479 ms |
79048 KB |
Output is correct |
32 |
Correct |
375 ms |
78936 KB |
Output is correct |
33 |
Correct |
228 ms |
78928 KB |
Output is correct |
34 |
Correct |
200 ms |
78936 KB |
Output is correct |
35 |
Correct |
367 ms |
78936 KB |
Output is correct |
36 |
Correct |
384 ms |
79036 KB |
Output is correct |
37 |
Execution timed out |
1020 ms |
78928 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |