#include"bits/stdc++.h"
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//bool plc[600000];*/
const int mod=1e9+7,maxn=250000;
int occ[250005];
int good[250006],a[505];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,sum=0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
sort(a,a+n);
//reverse(a,a+n);
//plc[0]=true;
vector <int> h;
occ[0]=1;
//yes.push_back(0);
for(int i=0;i<n;i++)
{
for(int j=maxn;j>=a[i];j--)
{
occ[j]+=occ[j-a[i]];
if(occ[j]>mod)
occ[j]-=mod;
}
}
//cout<<"HI"<<endl;
if(occ[sum/2]!=0&&sum%2==0)
{
for(int k=0;k<n;k++)
{
sum-=a[k];
for(int i=a[k];i<=maxn;i++)
{
if(occ[i-a[k]]!=0){
occ[i]-=occ[i-a[k]];
if(occ[i]<0)
occ[i]+=mod;
}
}
/*for(int i=0;i<=15;i++)
{
cout<<occ[i]<<" ";
}
cout<<"\n";*/
//cout<<"HELLO"<<endl;
for(int i=sum/2;i<=sum;i++)
{
int oth=i-(sum-i);
if(oth<=0||oth>=maxn)
continue;
if(occ[i]!=0){
good[oth]++;
//cout<<oth<<" ";
//cout<<oth<<" ";
}
}
for(int i=maxn;i>=a[k];i--)
{
if(occ[i-a[k]]!=0){
occ[i]+=occ[i-a[k]];
if(occ[i]>mod)
occ[i]-=mod;
}
}
//cout<<endl;
sum+=a[k];
}
}
for(int i=1;i<=maxn;i++)
{
if(good[i]==n){
//cout<<"???"<<endl;
h.push_back(i);
}
}
cout<<h.size()<<"\n";
for(auto i : h)
cout<<i<<" ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1236 KB |
Output is correct |
2 |
Correct |
7 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1236 KB |
Output is correct |
4 |
Correct |
5 ms |
1308 KB |
Output is correct |
5 |
Correct |
10 ms |
1236 KB |
Output is correct |
6 |
Correct |
7 ms |
1236 KB |
Output is correct |
7 |
Correct |
6 ms |
1236 KB |
Output is correct |
8 |
Correct |
11 ms |
1236 KB |
Output is correct |
9 |
Correct |
8 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1236 KB |
Output is correct |
2 |
Correct |
7 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1236 KB |
Output is correct |
4 |
Correct |
5 ms |
1308 KB |
Output is correct |
5 |
Correct |
10 ms |
1236 KB |
Output is correct |
6 |
Correct |
7 ms |
1236 KB |
Output is correct |
7 |
Correct |
6 ms |
1236 KB |
Output is correct |
8 |
Correct |
11 ms |
1236 KB |
Output is correct |
9 |
Correct |
8 ms |
1236 KB |
Output is correct |
10 |
Correct |
22 ms |
1296 KB |
Output is correct |
11 |
Correct |
24 ms |
1300 KB |
Output is correct |
12 |
Correct |
26 ms |
1364 KB |
Output is correct |
13 |
Correct |
23 ms |
1300 KB |
Output is correct |
14 |
Correct |
21 ms |
1304 KB |
Output is correct |
15 |
Correct |
22 ms |
1292 KB |
Output is correct |
16 |
Correct |
22 ms |
1236 KB |
Output is correct |
17 |
Correct |
14 ms |
1236 KB |
Output is correct |
18 |
Correct |
19 ms |
1300 KB |
Output is correct |
19 |
Correct |
19 ms |
1304 KB |
Output is correct |
20 |
Correct |
24 ms |
1304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1236 KB |
Output is correct |
2 |
Correct |
7 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1236 KB |
Output is correct |
4 |
Correct |
5 ms |
1308 KB |
Output is correct |
5 |
Correct |
10 ms |
1236 KB |
Output is correct |
6 |
Correct |
7 ms |
1236 KB |
Output is correct |
7 |
Correct |
6 ms |
1236 KB |
Output is correct |
8 |
Correct |
11 ms |
1236 KB |
Output is correct |
9 |
Correct |
8 ms |
1236 KB |
Output is correct |
10 |
Correct |
22 ms |
1296 KB |
Output is correct |
11 |
Correct |
24 ms |
1300 KB |
Output is correct |
12 |
Correct |
26 ms |
1364 KB |
Output is correct |
13 |
Correct |
23 ms |
1300 KB |
Output is correct |
14 |
Correct |
21 ms |
1304 KB |
Output is correct |
15 |
Correct |
22 ms |
1292 KB |
Output is correct |
16 |
Correct |
22 ms |
1236 KB |
Output is correct |
17 |
Correct |
14 ms |
1236 KB |
Output is correct |
18 |
Correct |
19 ms |
1300 KB |
Output is correct |
19 |
Correct |
19 ms |
1304 KB |
Output is correct |
20 |
Correct |
24 ms |
1304 KB |
Output is correct |
21 |
Correct |
47 ms |
1292 KB |
Output is correct |
22 |
Correct |
53 ms |
1292 KB |
Output is correct |
23 |
Correct |
36 ms |
1292 KB |
Output is correct |
24 |
Correct |
68 ms |
1296 KB |
Output is correct |
25 |
Correct |
75 ms |
1316 KB |
Output is correct |
26 |
Correct |
71 ms |
1424 KB |
Output is correct |
27 |
Correct |
81 ms |
1328 KB |
Output is correct |
28 |
Correct |
102 ms |
1336 KB |
Output is correct |
29 |
Correct |
73 ms |
1324 KB |
Output is correct |
30 |
Correct |
77 ms |
1356 KB |
Output is correct |
31 |
Correct |
74 ms |
1312 KB |
Output is correct |
32 |
Correct |
74 ms |
1312 KB |
Output is correct |
33 |
Correct |
73 ms |
1364 KB |
Output is correct |
34 |
Correct |
69 ms |
1320 KB |
Output is correct |
35 |
Correct |
70 ms |
1280 KB |
Output is correct |
36 |
Correct |
70 ms |
1288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1236 KB |
Output is correct |
2 |
Correct |
7 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1236 KB |
Output is correct |
4 |
Correct |
5 ms |
1308 KB |
Output is correct |
5 |
Correct |
10 ms |
1236 KB |
Output is correct |
6 |
Correct |
7 ms |
1236 KB |
Output is correct |
7 |
Correct |
6 ms |
1236 KB |
Output is correct |
8 |
Correct |
11 ms |
1236 KB |
Output is correct |
9 |
Correct |
8 ms |
1236 KB |
Output is correct |
10 |
Correct |
22 ms |
1296 KB |
Output is correct |
11 |
Correct |
24 ms |
1300 KB |
Output is correct |
12 |
Correct |
26 ms |
1364 KB |
Output is correct |
13 |
Correct |
23 ms |
1300 KB |
Output is correct |
14 |
Correct |
21 ms |
1304 KB |
Output is correct |
15 |
Correct |
22 ms |
1292 KB |
Output is correct |
16 |
Correct |
22 ms |
1236 KB |
Output is correct |
17 |
Correct |
14 ms |
1236 KB |
Output is correct |
18 |
Correct |
19 ms |
1300 KB |
Output is correct |
19 |
Correct |
19 ms |
1304 KB |
Output is correct |
20 |
Correct |
24 ms |
1304 KB |
Output is correct |
21 |
Correct |
47 ms |
1292 KB |
Output is correct |
22 |
Correct |
53 ms |
1292 KB |
Output is correct |
23 |
Correct |
36 ms |
1292 KB |
Output is correct |
24 |
Correct |
68 ms |
1296 KB |
Output is correct |
25 |
Correct |
75 ms |
1316 KB |
Output is correct |
26 |
Correct |
71 ms |
1424 KB |
Output is correct |
27 |
Correct |
81 ms |
1328 KB |
Output is correct |
28 |
Correct |
102 ms |
1336 KB |
Output is correct |
29 |
Correct |
73 ms |
1324 KB |
Output is correct |
30 |
Correct |
77 ms |
1356 KB |
Output is correct |
31 |
Correct |
74 ms |
1312 KB |
Output is correct |
32 |
Correct |
74 ms |
1312 KB |
Output is correct |
33 |
Correct |
73 ms |
1364 KB |
Output is correct |
34 |
Correct |
69 ms |
1320 KB |
Output is correct |
35 |
Correct |
70 ms |
1280 KB |
Output is correct |
36 |
Correct |
70 ms |
1288 KB |
Output is correct |
37 |
Correct |
142 ms |
1484 KB |
Output is correct |
38 |
Correct |
149 ms |
1484 KB |
Output is correct |
39 |
Correct |
175 ms |
1536 KB |
Output is correct |
40 |
Correct |
207 ms |
1536 KB |
Output is correct |
41 |
Correct |
196 ms |
1568 KB |
Output is correct |
42 |
Correct |
173 ms |
1524 KB |
Output is correct |
43 |
Correct |
177 ms |
1956 KB |
Output is correct |
44 |
Correct |
185 ms |
1808 KB |
Output is correct |
45 |
Correct |
195 ms |
1884 KB |
Output is correct |
46 |
Correct |
263 ms |
1412 KB |
Output is correct |
47 |
Correct |
175 ms |
1544 KB |
Output is correct |
48 |
Correct |
183 ms |
1776 KB |
Output is correct |
49 |
Correct |
189 ms |
1532 KB |
Output is correct |
50 |
Correct |
189 ms |
1540 KB |
Output is correct |
51 |
Correct |
67 ms |
1356 KB |
Output is correct |
52 |
Correct |
201 ms |
1944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1236 KB |
Output is correct |
2 |
Correct |
7 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1236 KB |
Output is correct |
4 |
Correct |
5 ms |
1308 KB |
Output is correct |
5 |
Correct |
10 ms |
1236 KB |
Output is correct |
6 |
Correct |
7 ms |
1236 KB |
Output is correct |
7 |
Correct |
6 ms |
1236 KB |
Output is correct |
8 |
Correct |
11 ms |
1236 KB |
Output is correct |
9 |
Correct |
8 ms |
1236 KB |
Output is correct |
10 |
Correct |
22 ms |
1296 KB |
Output is correct |
11 |
Correct |
24 ms |
1300 KB |
Output is correct |
12 |
Correct |
26 ms |
1364 KB |
Output is correct |
13 |
Correct |
23 ms |
1300 KB |
Output is correct |
14 |
Correct |
21 ms |
1304 KB |
Output is correct |
15 |
Correct |
22 ms |
1292 KB |
Output is correct |
16 |
Correct |
22 ms |
1236 KB |
Output is correct |
17 |
Correct |
14 ms |
1236 KB |
Output is correct |
18 |
Correct |
19 ms |
1300 KB |
Output is correct |
19 |
Correct |
19 ms |
1304 KB |
Output is correct |
20 |
Correct |
24 ms |
1304 KB |
Output is correct |
21 |
Correct |
47 ms |
1292 KB |
Output is correct |
22 |
Correct |
53 ms |
1292 KB |
Output is correct |
23 |
Correct |
36 ms |
1292 KB |
Output is correct |
24 |
Correct |
68 ms |
1296 KB |
Output is correct |
25 |
Correct |
75 ms |
1316 KB |
Output is correct |
26 |
Correct |
71 ms |
1424 KB |
Output is correct |
27 |
Correct |
81 ms |
1328 KB |
Output is correct |
28 |
Correct |
102 ms |
1336 KB |
Output is correct |
29 |
Correct |
73 ms |
1324 KB |
Output is correct |
30 |
Correct |
77 ms |
1356 KB |
Output is correct |
31 |
Correct |
74 ms |
1312 KB |
Output is correct |
32 |
Correct |
74 ms |
1312 KB |
Output is correct |
33 |
Correct |
73 ms |
1364 KB |
Output is correct |
34 |
Correct |
69 ms |
1320 KB |
Output is correct |
35 |
Correct |
70 ms |
1280 KB |
Output is correct |
36 |
Correct |
70 ms |
1288 KB |
Output is correct |
37 |
Correct |
142 ms |
1484 KB |
Output is correct |
38 |
Correct |
149 ms |
1484 KB |
Output is correct |
39 |
Correct |
175 ms |
1536 KB |
Output is correct |
40 |
Correct |
207 ms |
1536 KB |
Output is correct |
41 |
Correct |
196 ms |
1568 KB |
Output is correct |
42 |
Correct |
173 ms |
1524 KB |
Output is correct |
43 |
Correct |
177 ms |
1956 KB |
Output is correct |
44 |
Correct |
185 ms |
1808 KB |
Output is correct |
45 |
Correct |
195 ms |
1884 KB |
Output is correct |
46 |
Correct |
263 ms |
1412 KB |
Output is correct |
47 |
Correct |
175 ms |
1544 KB |
Output is correct |
48 |
Correct |
183 ms |
1776 KB |
Output is correct |
49 |
Correct |
189 ms |
1532 KB |
Output is correct |
50 |
Correct |
189 ms |
1540 KB |
Output is correct |
51 |
Correct |
67 ms |
1356 KB |
Output is correct |
52 |
Correct |
201 ms |
1944 KB |
Output is correct |
53 |
Correct |
222 ms |
1792 KB |
Output is correct |
54 |
Correct |
281 ms |
1800 KB |
Output is correct |
55 |
Correct |
258 ms |
2324 KB |
Output is correct |
56 |
Correct |
258 ms |
1996 KB |
Output is correct |
57 |
Correct |
334 ms |
2388 KB |
Output is correct |
58 |
Correct |
261 ms |
1908 KB |
Output is correct |
59 |
Correct |
294 ms |
2052 KB |
Output is correct |
60 |
Correct |
88 ms |
1236 KB |
Output is correct |
61 |
Correct |
268 ms |
2192 KB |
Output is correct |
62 |
Correct |
299 ms |
2176 KB |
Output is correct |
63 |
Correct |
268 ms |
2192 KB |
Output is correct |
64 |
Correct |
257 ms |
2196 KB |
Output is correct |
65 |
Correct |
290 ms |
1464 KB |
Output is correct |
66 |
Correct |
241 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1236 KB |
Output is correct |
2 |
Correct |
7 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1236 KB |
Output is correct |
4 |
Correct |
5 ms |
1308 KB |
Output is correct |
5 |
Correct |
10 ms |
1236 KB |
Output is correct |
6 |
Correct |
7 ms |
1236 KB |
Output is correct |
7 |
Correct |
6 ms |
1236 KB |
Output is correct |
8 |
Correct |
11 ms |
1236 KB |
Output is correct |
9 |
Correct |
8 ms |
1236 KB |
Output is correct |
10 |
Correct |
22 ms |
1296 KB |
Output is correct |
11 |
Correct |
24 ms |
1300 KB |
Output is correct |
12 |
Correct |
26 ms |
1364 KB |
Output is correct |
13 |
Correct |
23 ms |
1300 KB |
Output is correct |
14 |
Correct |
21 ms |
1304 KB |
Output is correct |
15 |
Correct |
22 ms |
1292 KB |
Output is correct |
16 |
Correct |
22 ms |
1236 KB |
Output is correct |
17 |
Correct |
14 ms |
1236 KB |
Output is correct |
18 |
Correct |
19 ms |
1300 KB |
Output is correct |
19 |
Correct |
19 ms |
1304 KB |
Output is correct |
20 |
Correct |
24 ms |
1304 KB |
Output is correct |
21 |
Correct |
47 ms |
1292 KB |
Output is correct |
22 |
Correct |
53 ms |
1292 KB |
Output is correct |
23 |
Correct |
36 ms |
1292 KB |
Output is correct |
24 |
Correct |
68 ms |
1296 KB |
Output is correct |
25 |
Correct |
75 ms |
1316 KB |
Output is correct |
26 |
Correct |
71 ms |
1424 KB |
Output is correct |
27 |
Correct |
81 ms |
1328 KB |
Output is correct |
28 |
Correct |
102 ms |
1336 KB |
Output is correct |
29 |
Correct |
73 ms |
1324 KB |
Output is correct |
30 |
Correct |
77 ms |
1356 KB |
Output is correct |
31 |
Correct |
74 ms |
1312 KB |
Output is correct |
32 |
Correct |
74 ms |
1312 KB |
Output is correct |
33 |
Correct |
73 ms |
1364 KB |
Output is correct |
34 |
Correct |
69 ms |
1320 KB |
Output is correct |
35 |
Correct |
70 ms |
1280 KB |
Output is correct |
36 |
Correct |
70 ms |
1288 KB |
Output is correct |
37 |
Correct |
142 ms |
1484 KB |
Output is correct |
38 |
Correct |
149 ms |
1484 KB |
Output is correct |
39 |
Correct |
175 ms |
1536 KB |
Output is correct |
40 |
Correct |
207 ms |
1536 KB |
Output is correct |
41 |
Correct |
196 ms |
1568 KB |
Output is correct |
42 |
Correct |
173 ms |
1524 KB |
Output is correct |
43 |
Correct |
177 ms |
1956 KB |
Output is correct |
44 |
Correct |
185 ms |
1808 KB |
Output is correct |
45 |
Correct |
195 ms |
1884 KB |
Output is correct |
46 |
Correct |
263 ms |
1412 KB |
Output is correct |
47 |
Correct |
175 ms |
1544 KB |
Output is correct |
48 |
Correct |
183 ms |
1776 KB |
Output is correct |
49 |
Correct |
189 ms |
1532 KB |
Output is correct |
50 |
Correct |
189 ms |
1540 KB |
Output is correct |
51 |
Correct |
67 ms |
1356 KB |
Output is correct |
52 |
Correct |
201 ms |
1944 KB |
Output is correct |
53 |
Correct |
222 ms |
1792 KB |
Output is correct |
54 |
Correct |
281 ms |
1800 KB |
Output is correct |
55 |
Correct |
258 ms |
2324 KB |
Output is correct |
56 |
Correct |
258 ms |
1996 KB |
Output is correct |
57 |
Correct |
334 ms |
2388 KB |
Output is correct |
58 |
Correct |
261 ms |
1908 KB |
Output is correct |
59 |
Correct |
294 ms |
2052 KB |
Output is correct |
60 |
Correct |
88 ms |
1236 KB |
Output is correct |
61 |
Correct |
268 ms |
2192 KB |
Output is correct |
62 |
Correct |
299 ms |
2176 KB |
Output is correct |
63 |
Correct |
268 ms |
2192 KB |
Output is correct |
64 |
Correct |
257 ms |
2196 KB |
Output is correct |
65 |
Correct |
290 ms |
1464 KB |
Output is correct |
66 |
Correct |
241 ms |
1484 KB |
Output is correct |
67 |
Correct |
317 ms |
2048 KB |
Output is correct |
68 |
Correct |
127 ms |
1236 KB |
Output is correct |
69 |
Correct |
411 ms |
3328 KB |
Output is correct |
70 |
Correct |
413 ms |
2560 KB |
Output is correct |
71 |
Correct |
387 ms |
2560 KB |
Output is correct |
72 |
Correct |
393 ms |
1848 KB |
Output is correct |
73 |
Correct |
369 ms |
1672 KB |
Output is correct |
74 |
Correct |
429 ms |
3340 KB |
Output is correct |
75 |
Correct |
398 ms |
2988 KB |
Output is correct |
76 |
Correct |
460 ms |
3404 KB |
Output is correct |
77 |
Correct |
469 ms |
3492 KB |
Output is correct |