#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
const ll mod=1e9+7;
const ll maxval=500*500;
ll cnt[maxval+5];
ll n,arr[505];
ll valid[maxval+5];
ll sum=0;
void add(ll x){
for(int i=maxval-x;i>=0;i--){
cnt[i+x]+=cnt[i];
cnt[i+x]%=mod;
}
}
void rem(ll x){
for(int i=0;i<=maxval-x;i++){
cnt[i+x]-=cnt[i];
cnt[i+x]+=mod;
cnt[i+x]%=mod;
}
}
void solve(){
cnt[0]=1;
cin>>n;
for(int i=1;i<=n;i++){
cin>>arr[i];
sum+=arr[i];
add(arr[i]);
}
if(sum%2==1||cnt[sum/2]==0){
co 0;
return;
}
for(int i=1;i<=n;i++){
rem(arr[i]);
sum-=arr[i];
for(int j=0;j<=maxval;j++){
if(sum-2*j>0&&cnt[j]>0&&cnt[sum-j]>0) valid[sum-2*j]++;
}
sum+=arr[i];
add(arr[i]);
}
vector<ll>answers;
for(int i=1;i<=maxval;i++){
if(valid[i]==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 |
8 ms |
2392 KB |
Output is correct |
2 |
Correct |
8 ms |
2424 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
6 ms |
2428 KB |
Output is correct |
5 |
Correct |
15 ms |
2396 KB |
Output is correct |
6 |
Correct |
11 ms |
2396 KB |
Output is correct |
7 |
Correct |
8 ms |
2396 KB |
Output is correct |
8 |
Correct |
15 ms |
2396 KB |
Output is correct |
9 |
Correct |
12 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2392 KB |
Output is correct |
2 |
Correct |
8 ms |
2424 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
6 ms |
2428 KB |
Output is correct |
5 |
Correct |
15 ms |
2396 KB |
Output is correct |
6 |
Correct |
11 ms |
2396 KB |
Output is correct |
7 |
Correct |
8 ms |
2396 KB |
Output is correct |
8 |
Correct |
15 ms |
2396 KB |
Output is correct |
9 |
Correct |
12 ms |
2396 KB |
Output is correct |
10 |
Correct |
34 ms |
2392 KB |
Output is correct |
11 |
Correct |
38 ms |
2392 KB |
Output is correct |
12 |
Correct |
35 ms |
2268 KB |
Output is correct |
13 |
Correct |
32 ms |
2396 KB |
Output is correct |
14 |
Correct |
34 ms |
2396 KB |
Output is correct |
15 |
Correct |
37 ms |
2396 KB |
Output is correct |
16 |
Correct |
42 ms |
2396 KB |
Output is correct |
17 |
Correct |
23 ms |
2396 KB |
Output is correct |
18 |
Correct |
30 ms |
2396 KB |
Output is correct |
19 |
Correct |
33 ms |
2396 KB |
Output is correct |
20 |
Correct |
34 ms |
2432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2392 KB |
Output is correct |
2 |
Correct |
8 ms |
2424 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
6 ms |
2428 KB |
Output is correct |
5 |
Correct |
15 ms |
2396 KB |
Output is correct |
6 |
Correct |
11 ms |
2396 KB |
Output is correct |
7 |
Correct |
8 ms |
2396 KB |
Output is correct |
8 |
Correct |
15 ms |
2396 KB |
Output is correct |
9 |
Correct |
12 ms |
2396 KB |
Output is correct |
10 |
Correct |
34 ms |
2392 KB |
Output is correct |
11 |
Correct |
38 ms |
2392 KB |
Output is correct |
12 |
Correct |
35 ms |
2268 KB |
Output is correct |
13 |
Correct |
32 ms |
2396 KB |
Output is correct |
14 |
Correct |
34 ms |
2396 KB |
Output is correct |
15 |
Correct |
37 ms |
2396 KB |
Output is correct |
16 |
Correct |
42 ms |
2396 KB |
Output is correct |
17 |
Correct |
23 ms |
2396 KB |
Output is correct |
18 |
Correct |
30 ms |
2396 KB |
Output is correct |
19 |
Correct |
33 ms |
2396 KB |
Output is correct |
20 |
Correct |
34 ms |
2432 KB |
Output is correct |
21 |
Correct |
73 ms |
2396 KB |
Output is correct |
22 |
Correct |
83 ms |
2396 KB |
Output is correct |
23 |
Correct |
57 ms |
2392 KB |
Output is correct |
24 |
Correct |
108 ms |
2396 KB |
Output is correct |
25 |
Correct |
103 ms |
2392 KB |
Output is correct |
26 |
Correct |
110 ms |
2396 KB |
Output is correct |
27 |
Correct |
125 ms |
2396 KB |
Output is correct |
28 |
Correct |
114 ms |
2392 KB |
Output is correct |
29 |
Correct |
114 ms |
2396 KB |
Output is correct |
30 |
Correct |
113 ms |
2392 KB |
Output is correct |
31 |
Correct |
110 ms |
2392 KB |
Output is correct |
32 |
Correct |
115 ms |
2392 KB |
Output is correct |
33 |
Correct |
109 ms |
2484 KB |
Output is correct |
34 |
Correct |
109 ms |
2392 KB |
Output is correct |
35 |
Correct |
119 ms |
2480 KB |
Output is correct |
36 |
Correct |
120 ms |
2440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2392 KB |
Output is correct |
2 |
Correct |
8 ms |
2424 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
6 ms |
2428 KB |
Output is correct |
5 |
Correct |
15 ms |
2396 KB |
Output is correct |
6 |
Correct |
11 ms |
2396 KB |
Output is correct |
7 |
Correct |
8 ms |
2396 KB |
Output is correct |
8 |
Correct |
15 ms |
2396 KB |
Output is correct |
9 |
Correct |
12 ms |
2396 KB |
Output is correct |
10 |
Correct |
34 ms |
2392 KB |
Output is correct |
11 |
Correct |
38 ms |
2392 KB |
Output is correct |
12 |
Correct |
35 ms |
2268 KB |
Output is correct |
13 |
Correct |
32 ms |
2396 KB |
Output is correct |
14 |
Correct |
34 ms |
2396 KB |
Output is correct |
15 |
Correct |
37 ms |
2396 KB |
Output is correct |
16 |
Correct |
42 ms |
2396 KB |
Output is correct |
17 |
Correct |
23 ms |
2396 KB |
Output is correct |
18 |
Correct |
30 ms |
2396 KB |
Output is correct |
19 |
Correct |
33 ms |
2396 KB |
Output is correct |
20 |
Correct |
34 ms |
2432 KB |
Output is correct |
21 |
Correct |
73 ms |
2396 KB |
Output is correct |
22 |
Correct |
83 ms |
2396 KB |
Output is correct |
23 |
Correct |
57 ms |
2392 KB |
Output is correct |
24 |
Correct |
108 ms |
2396 KB |
Output is correct |
25 |
Correct |
103 ms |
2392 KB |
Output is correct |
26 |
Correct |
110 ms |
2396 KB |
Output is correct |
27 |
Correct |
125 ms |
2396 KB |
Output is correct |
28 |
Correct |
114 ms |
2392 KB |
Output is correct |
29 |
Correct |
114 ms |
2396 KB |
Output is correct |
30 |
Correct |
113 ms |
2392 KB |
Output is correct |
31 |
Correct |
110 ms |
2392 KB |
Output is correct |
32 |
Correct |
115 ms |
2392 KB |
Output is correct |
33 |
Correct |
109 ms |
2484 KB |
Output is correct |
34 |
Correct |
109 ms |
2392 KB |
Output is correct |
35 |
Correct |
119 ms |
2480 KB |
Output is correct |
36 |
Correct |
120 ms |
2440 KB |
Output is correct |
37 |
Correct |
220 ms |
2676 KB |
Output is correct |
38 |
Correct |
217 ms |
2660 KB |
Output is correct |
39 |
Correct |
285 ms |
2660 KB |
Output is correct |
40 |
Correct |
309 ms |
2912 KB |
Output is correct |
41 |
Correct |
304 ms |
2900 KB |
Output is correct |
42 |
Correct |
275 ms |
2900 KB |
Output is correct |
43 |
Correct |
267 ms |
3308 KB |
Output is correct |
44 |
Correct |
280 ms |
3324 KB |
Output is correct |
45 |
Correct |
276 ms |
3308 KB |
Output is correct |
46 |
Correct |
309 ms |
2644 KB |
Output is correct |
47 |
Correct |
276 ms |
2896 KB |
Output is correct |
48 |
Correct |
276 ms |
3188 KB |
Output is correct |
49 |
Correct |
272 ms |
2900 KB |
Output is correct |
50 |
Correct |
279 ms |
2896 KB |
Output is correct |
51 |
Correct |
71 ms |
2392 KB |
Output is correct |
52 |
Correct |
297 ms |
3288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2392 KB |
Output is correct |
2 |
Correct |
8 ms |
2424 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
6 ms |
2428 KB |
Output is correct |
5 |
Correct |
15 ms |
2396 KB |
Output is correct |
6 |
Correct |
11 ms |
2396 KB |
Output is correct |
7 |
Correct |
8 ms |
2396 KB |
Output is correct |
8 |
Correct |
15 ms |
2396 KB |
Output is correct |
9 |
Correct |
12 ms |
2396 KB |
Output is correct |
10 |
Correct |
34 ms |
2392 KB |
Output is correct |
11 |
Correct |
38 ms |
2392 KB |
Output is correct |
12 |
Correct |
35 ms |
2268 KB |
Output is correct |
13 |
Correct |
32 ms |
2396 KB |
Output is correct |
14 |
Correct |
34 ms |
2396 KB |
Output is correct |
15 |
Correct |
37 ms |
2396 KB |
Output is correct |
16 |
Correct |
42 ms |
2396 KB |
Output is correct |
17 |
Correct |
23 ms |
2396 KB |
Output is correct |
18 |
Correct |
30 ms |
2396 KB |
Output is correct |
19 |
Correct |
33 ms |
2396 KB |
Output is correct |
20 |
Correct |
34 ms |
2432 KB |
Output is correct |
21 |
Correct |
73 ms |
2396 KB |
Output is correct |
22 |
Correct |
83 ms |
2396 KB |
Output is correct |
23 |
Correct |
57 ms |
2392 KB |
Output is correct |
24 |
Correct |
108 ms |
2396 KB |
Output is correct |
25 |
Correct |
103 ms |
2392 KB |
Output is correct |
26 |
Correct |
110 ms |
2396 KB |
Output is correct |
27 |
Correct |
125 ms |
2396 KB |
Output is correct |
28 |
Correct |
114 ms |
2392 KB |
Output is correct |
29 |
Correct |
114 ms |
2396 KB |
Output is correct |
30 |
Correct |
113 ms |
2392 KB |
Output is correct |
31 |
Correct |
110 ms |
2392 KB |
Output is correct |
32 |
Correct |
115 ms |
2392 KB |
Output is correct |
33 |
Correct |
109 ms |
2484 KB |
Output is correct |
34 |
Correct |
109 ms |
2392 KB |
Output is correct |
35 |
Correct |
119 ms |
2480 KB |
Output is correct |
36 |
Correct |
120 ms |
2440 KB |
Output is correct |
37 |
Correct |
220 ms |
2676 KB |
Output is correct |
38 |
Correct |
217 ms |
2660 KB |
Output is correct |
39 |
Correct |
285 ms |
2660 KB |
Output is correct |
40 |
Correct |
309 ms |
2912 KB |
Output is correct |
41 |
Correct |
304 ms |
2900 KB |
Output is correct |
42 |
Correct |
275 ms |
2900 KB |
Output is correct |
43 |
Correct |
267 ms |
3308 KB |
Output is correct |
44 |
Correct |
280 ms |
3324 KB |
Output is correct |
45 |
Correct |
276 ms |
3308 KB |
Output is correct |
46 |
Correct |
309 ms |
2644 KB |
Output is correct |
47 |
Correct |
276 ms |
2896 KB |
Output is correct |
48 |
Correct |
276 ms |
3188 KB |
Output is correct |
49 |
Correct |
272 ms |
2900 KB |
Output is correct |
50 |
Correct |
279 ms |
2896 KB |
Output is correct |
51 |
Correct |
71 ms |
2392 KB |
Output is correct |
52 |
Correct |
297 ms |
3288 KB |
Output is correct |
53 |
Correct |
331 ms |
3156 KB |
Output is correct |
54 |
Correct |
382 ms |
3324 KB |
Output is correct |
55 |
Correct |
398 ms |
3916 KB |
Output is correct |
56 |
Correct |
333 ms |
3284 KB |
Output is correct |
57 |
Correct |
389 ms |
4048 KB |
Output is correct |
58 |
Correct |
383 ms |
3284 KB |
Output is correct |
59 |
Correct |
390 ms |
3880 KB |
Output is correct |
60 |
Correct |
96 ms |
2396 KB |
Output is correct |
61 |
Correct |
385 ms |
3560 KB |
Output is correct |
62 |
Correct |
355 ms |
3800 KB |
Output is correct |
63 |
Correct |
371 ms |
3796 KB |
Output is correct |
64 |
Correct |
346 ms |
3796 KB |
Output is correct |
65 |
Correct |
347 ms |
2656 KB |
Output is correct |
66 |
Correct |
346 ms |
2900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2392 KB |
Output is correct |
2 |
Correct |
8 ms |
2424 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
6 ms |
2428 KB |
Output is correct |
5 |
Correct |
15 ms |
2396 KB |
Output is correct |
6 |
Correct |
11 ms |
2396 KB |
Output is correct |
7 |
Correct |
8 ms |
2396 KB |
Output is correct |
8 |
Correct |
15 ms |
2396 KB |
Output is correct |
9 |
Correct |
12 ms |
2396 KB |
Output is correct |
10 |
Correct |
34 ms |
2392 KB |
Output is correct |
11 |
Correct |
38 ms |
2392 KB |
Output is correct |
12 |
Correct |
35 ms |
2268 KB |
Output is correct |
13 |
Correct |
32 ms |
2396 KB |
Output is correct |
14 |
Correct |
34 ms |
2396 KB |
Output is correct |
15 |
Correct |
37 ms |
2396 KB |
Output is correct |
16 |
Correct |
42 ms |
2396 KB |
Output is correct |
17 |
Correct |
23 ms |
2396 KB |
Output is correct |
18 |
Correct |
30 ms |
2396 KB |
Output is correct |
19 |
Correct |
33 ms |
2396 KB |
Output is correct |
20 |
Correct |
34 ms |
2432 KB |
Output is correct |
21 |
Correct |
73 ms |
2396 KB |
Output is correct |
22 |
Correct |
83 ms |
2396 KB |
Output is correct |
23 |
Correct |
57 ms |
2392 KB |
Output is correct |
24 |
Correct |
108 ms |
2396 KB |
Output is correct |
25 |
Correct |
103 ms |
2392 KB |
Output is correct |
26 |
Correct |
110 ms |
2396 KB |
Output is correct |
27 |
Correct |
125 ms |
2396 KB |
Output is correct |
28 |
Correct |
114 ms |
2392 KB |
Output is correct |
29 |
Correct |
114 ms |
2396 KB |
Output is correct |
30 |
Correct |
113 ms |
2392 KB |
Output is correct |
31 |
Correct |
110 ms |
2392 KB |
Output is correct |
32 |
Correct |
115 ms |
2392 KB |
Output is correct |
33 |
Correct |
109 ms |
2484 KB |
Output is correct |
34 |
Correct |
109 ms |
2392 KB |
Output is correct |
35 |
Correct |
119 ms |
2480 KB |
Output is correct |
36 |
Correct |
120 ms |
2440 KB |
Output is correct |
37 |
Correct |
220 ms |
2676 KB |
Output is correct |
38 |
Correct |
217 ms |
2660 KB |
Output is correct |
39 |
Correct |
285 ms |
2660 KB |
Output is correct |
40 |
Correct |
309 ms |
2912 KB |
Output is correct |
41 |
Correct |
304 ms |
2900 KB |
Output is correct |
42 |
Correct |
275 ms |
2900 KB |
Output is correct |
43 |
Correct |
267 ms |
3308 KB |
Output is correct |
44 |
Correct |
280 ms |
3324 KB |
Output is correct |
45 |
Correct |
276 ms |
3308 KB |
Output is correct |
46 |
Correct |
309 ms |
2644 KB |
Output is correct |
47 |
Correct |
276 ms |
2896 KB |
Output is correct |
48 |
Correct |
276 ms |
3188 KB |
Output is correct |
49 |
Correct |
272 ms |
2900 KB |
Output is correct |
50 |
Correct |
279 ms |
2896 KB |
Output is correct |
51 |
Correct |
71 ms |
2392 KB |
Output is correct |
52 |
Correct |
297 ms |
3288 KB |
Output is correct |
53 |
Correct |
331 ms |
3156 KB |
Output is correct |
54 |
Correct |
382 ms |
3324 KB |
Output is correct |
55 |
Correct |
398 ms |
3916 KB |
Output is correct |
56 |
Correct |
333 ms |
3284 KB |
Output is correct |
57 |
Correct |
389 ms |
4048 KB |
Output is correct |
58 |
Correct |
383 ms |
3284 KB |
Output is correct |
59 |
Correct |
390 ms |
3880 KB |
Output is correct |
60 |
Correct |
96 ms |
2396 KB |
Output is correct |
61 |
Correct |
385 ms |
3560 KB |
Output is correct |
62 |
Correct |
355 ms |
3800 KB |
Output is correct |
63 |
Correct |
371 ms |
3796 KB |
Output is correct |
64 |
Correct |
346 ms |
3796 KB |
Output is correct |
65 |
Correct |
347 ms |
2656 KB |
Output is correct |
66 |
Correct |
346 ms |
2900 KB |
Output is correct |
67 |
Correct |
447 ms |
3564 KB |
Output is correct |
68 |
Correct |
141 ms |
2396 KB |
Output is correct |
69 |
Correct |
575 ms |
5580 KB |
Output is correct |
70 |
Correct |
561 ms |
4308 KB |
Output is correct |
71 |
Correct |
559 ms |
4304 KB |
Output is correct |
72 |
Correct |
548 ms |
3156 KB |
Output is correct |
73 |
Correct |
556 ms |
3176 KB |
Output is correct |
74 |
Correct |
559 ms |
5836 KB |
Output is correct |
75 |
Correct |
581 ms |
5104 KB |
Output is correct |
76 |
Correct |
579 ms |
5840 KB |
Output is correct |
77 |
Correct |
566 ms |
5840 KB |
Output is correct |