///////////////////////////
// INFO //
// //
// Handle -> Scayre //
// //
// Template vers. 1.1 //
// //
// It'll be accepted //
// //
///////////////////////////
//████╗████████╗██╗███████╗══███╗═══███╗████████╗════//
//═██╔╝═══██╔══╝╚█║██╔════╝══████╗═████║██╔═════╝═══//
//═██║════██║════╚╝███████╗══██╔████╔██║█████╗══════//
//═██║════██║══════╚════██║══██║╚██╔╝██║██╔══╝══════//
//████╗═══██║══════███████║══██║═╚═╝═██║███████╗═════//
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <complex>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
#define f first
#define s second
#define inf (int)1e9 + 7
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp(x,y) make_pair(x,y)
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
#define pb push_back
#define ppb pop_back
#define bitcoin __builtin_popcount
#define endl "\n"
#define in(x) insert(x)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define pw2(x) (1<<x) //2^x
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
#define sqr(x) ((x) * 1ll * (x))
#define UpdateRandom srand (time(NULL));
using namespace std;
const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;
int n;
int a[N];
ll sum;
ll dp[N];
int u[N];
vector<int> v;
void add(int x){
sum+=x;
for(int i=sum;i>=x;i--){
dp[i]+=dp[i-x];
}
}
void del(int x){
for(int i=x;i<=sum;i++){
dp[i]-=dp[i-x];
}
sum-=x;
}
int main(){
#ifdef IOI2019
freopen ("in.txt", "r", stdin);
#endif
NFS
cin >> n;
dp[0]=1;
for(int i=1;i<=n;i++){
cin >> a[i];
add(a[i]);
}
if(sum%2!=0 || dp[sum/2]==0){
cout << 0 << endl;
ioi
}
for(int i=1;i<=n;i++){
del(a[i]);
for(int j=1;j<=sum+a[i];j++){
if(dp[(sum+j)/2]==0 || (sum+j)%2!=0){
u[j]=1;
}
}
add(a[i]);
}
for(int i=1;i<=sum;i++){
if(!u[i]){
v.pb(i);
}
}
cout << sz(v) << endl;
for(int i=0;i<sz(v);i++){
cout << v[i] << ' ';
}
#ifdef IOI2019
cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl;
#endif
ioi
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
10 |
Correct |
2 ms |
692 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
780 KB |
Output is correct |
14 |
Correct |
2 ms |
912 KB |
Output is correct |
15 |
Correct |
2 ms |
912 KB |
Output is correct |
16 |
Correct |
2 ms |
912 KB |
Output is correct |
17 |
Correct |
2 ms |
912 KB |
Output is correct |
18 |
Correct |
2 ms |
912 KB |
Output is correct |
19 |
Correct |
3 ms |
912 KB |
Output is correct |
20 |
Correct |
3 ms |
912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
10 |
Correct |
2 ms |
692 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
780 KB |
Output is correct |
14 |
Correct |
2 ms |
912 KB |
Output is correct |
15 |
Correct |
2 ms |
912 KB |
Output is correct |
16 |
Correct |
2 ms |
912 KB |
Output is correct |
17 |
Correct |
2 ms |
912 KB |
Output is correct |
18 |
Correct |
2 ms |
912 KB |
Output is correct |
19 |
Correct |
3 ms |
912 KB |
Output is correct |
20 |
Correct |
3 ms |
912 KB |
Output is correct |
21 |
Correct |
3 ms |
912 KB |
Output is correct |
22 |
Correct |
4 ms |
912 KB |
Output is correct |
23 |
Correct |
3 ms |
912 KB |
Output is correct |
24 |
Correct |
4 ms |
972 KB |
Output is correct |
25 |
Correct |
6 ms |
992 KB |
Output is correct |
26 |
Correct |
7 ms |
996 KB |
Output is correct |
27 |
Correct |
6 ms |
1020 KB |
Output is correct |
28 |
Correct |
7 ms |
1024 KB |
Output is correct |
29 |
Correct |
6 ms |
1024 KB |
Output is correct |
30 |
Correct |
4 ms |
1024 KB |
Output is correct |
31 |
Correct |
5 ms |
1032 KB |
Output is correct |
32 |
Correct |
4 ms |
1036 KB |
Output is correct |
33 |
Correct |
5 ms |
1040 KB |
Output is correct |
34 |
Correct |
6 ms |
1044 KB |
Output is correct |
35 |
Correct |
6 ms |
1044 KB |
Output is correct |
36 |
Correct |
4 ms |
1044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
10 |
Correct |
2 ms |
692 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
780 KB |
Output is correct |
14 |
Correct |
2 ms |
912 KB |
Output is correct |
15 |
Correct |
2 ms |
912 KB |
Output is correct |
16 |
Correct |
2 ms |
912 KB |
Output is correct |
17 |
Correct |
2 ms |
912 KB |
Output is correct |
18 |
Correct |
2 ms |
912 KB |
Output is correct |
19 |
Correct |
3 ms |
912 KB |
Output is correct |
20 |
Correct |
3 ms |
912 KB |
Output is correct |
21 |
Correct |
3 ms |
912 KB |
Output is correct |
22 |
Correct |
4 ms |
912 KB |
Output is correct |
23 |
Correct |
3 ms |
912 KB |
Output is correct |
24 |
Correct |
4 ms |
972 KB |
Output is correct |
25 |
Correct |
6 ms |
992 KB |
Output is correct |
26 |
Correct |
7 ms |
996 KB |
Output is correct |
27 |
Correct |
6 ms |
1020 KB |
Output is correct |
28 |
Correct |
7 ms |
1024 KB |
Output is correct |
29 |
Correct |
6 ms |
1024 KB |
Output is correct |
30 |
Correct |
4 ms |
1024 KB |
Output is correct |
31 |
Correct |
5 ms |
1032 KB |
Output is correct |
32 |
Correct |
4 ms |
1036 KB |
Output is correct |
33 |
Correct |
5 ms |
1040 KB |
Output is correct |
34 |
Correct |
6 ms |
1044 KB |
Output is correct |
35 |
Correct |
6 ms |
1044 KB |
Output is correct |
36 |
Correct |
4 ms |
1044 KB |
Output is correct |
37 |
Correct |
15 ms |
1312 KB |
Output is correct |
38 |
Correct |
17 ms |
1316 KB |
Output is correct |
39 |
Correct |
54 ms |
1704 KB |
Output is correct |
40 |
Correct |
31 ms |
1704 KB |
Output is correct |
41 |
Correct |
65 ms |
1856 KB |
Output is correct |
42 |
Correct |
27 ms |
1856 KB |
Output is correct |
43 |
Correct |
47 ms |
1908 KB |
Output is correct |
44 |
Correct |
50 ms |
1996 KB |
Output is correct |
45 |
Correct |
49 ms |
2132 KB |
Output is correct |
46 |
Correct |
36 ms |
2132 KB |
Output is correct |
47 |
Correct |
29 ms |
2132 KB |
Output is correct |
48 |
Correct |
60 ms |
2132 KB |
Output is correct |
49 |
Correct |
59 ms |
2132 KB |
Output is correct |
50 |
Correct |
30 ms |
2132 KB |
Output is correct |
51 |
Correct |
6 ms |
2132 KB |
Output is correct |
52 |
Correct |
65 ms |
2156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
10 |
Correct |
2 ms |
692 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
780 KB |
Output is correct |
14 |
Correct |
2 ms |
912 KB |
Output is correct |
15 |
Correct |
2 ms |
912 KB |
Output is correct |
16 |
Correct |
2 ms |
912 KB |
Output is correct |
17 |
Correct |
2 ms |
912 KB |
Output is correct |
18 |
Correct |
2 ms |
912 KB |
Output is correct |
19 |
Correct |
3 ms |
912 KB |
Output is correct |
20 |
Correct |
3 ms |
912 KB |
Output is correct |
21 |
Correct |
3 ms |
912 KB |
Output is correct |
22 |
Correct |
4 ms |
912 KB |
Output is correct |
23 |
Correct |
3 ms |
912 KB |
Output is correct |
24 |
Correct |
4 ms |
972 KB |
Output is correct |
25 |
Correct |
6 ms |
992 KB |
Output is correct |
26 |
Correct |
7 ms |
996 KB |
Output is correct |
27 |
Correct |
6 ms |
1020 KB |
Output is correct |
28 |
Correct |
7 ms |
1024 KB |
Output is correct |
29 |
Correct |
6 ms |
1024 KB |
Output is correct |
30 |
Correct |
4 ms |
1024 KB |
Output is correct |
31 |
Correct |
5 ms |
1032 KB |
Output is correct |
32 |
Correct |
4 ms |
1036 KB |
Output is correct |
33 |
Correct |
5 ms |
1040 KB |
Output is correct |
34 |
Correct |
6 ms |
1044 KB |
Output is correct |
35 |
Correct |
6 ms |
1044 KB |
Output is correct |
36 |
Correct |
4 ms |
1044 KB |
Output is correct |
37 |
Correct |
15 ms |
1312 KB |
Output is correct |
38 |
Correct |
17 ms |
1316 KB |
Output is correct |
39 |
Correct |
54 ms |
1704 KB |
Output is correct |
40 |
Correct |
31 ms |
1704 KB |
Output is correct |
41 |
Correct |
65 ms |
1856 KB |
Output is correct |
42 |
Correct |
27 ms |
1856 KB |
Output is correct |
43 |
Correct |
47 ms |
1908 KB |
Output is correct |
44 |
Correct |
50 ms |
1996 KB |
Output is correct |
45 |
Correct |
49 ms |
2132 KB |
Output is correct |
46 |
Correct |
36 ms |
2132 KB |
Output is correct |
47 |
Correct |
29 ms |
2132 KB |
Output is correct |
48 |
Correct |
60 ms |
2132 KB |
Output is correct |
49 |
Correct |
59 ms |
2132 KB |
Output is correct |
50 |
Correct |
30 ms |
2132 KB |
Output is correct |
51 |
Correct |
6 ms |
2132 KB |
Output is correct |
52 |
Correct |
65 ms |
2156 KB |
Output is correct |
53 |
Correct |
47 ms |
2156 KB |
Output is correct |
54 |
Correct |
66 ms |
2156 KB |
Output is correct |
55 |
Correct |
130 ms |
2936 KB |
Output is correct |
56 |
Correct |
58 ms |
2936 KB |
Output is correct |
57 |
Correct |
137 ms |
3072 KB |
Output is correct |
58 |
Correct |
73 ms |
3072 KB |
Output is correct |
59 |
Correct |
92 ms |
3072 KB |
Output is correct |
60 |
Correct |
11 ms |
3072 KB |
Output is correct |
61 |
Correct |
98 ms |
3072 KB |
Output is correct |
62 |
Correct |
102 ms |
3072 KB |
Output is correct |
63 |
Correct |
109 ms |
3072 KB |
Output is correct |
64 |
Correct |
106 ms |
3072 KB |
Output is correct |
65 |
Correct |
59 ms |
3072 KB |
Output is correct |
66 |
Correct |
69 ms |
3072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
10 |
Correct |
2 ms |
692 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
780 KB |
Output is correct |
14 |
Correct |
2 ms |
912 KB |
Output is correct |
15 |
Correct |
2 ms |
912 KB |
Output is correct |
16 |
Correct |
2 ms |
912 KB |
Output is correct |
17 |
Correct |
2 ms |
912 KB |
Output is correct |
18 |
Correct |
2 ms |
912 KB |
Output is correct |
19 |
Correct |
3 ms |
912 KB |
Output is correct |
20 |
Correct |
3 ms |
912 KB |
Output is correct |
21 |
Correct |
3 ms |
912 KB |
Output is correct |
22 |
Correct |
4 ms |
912 KB |
Output is correct |
23 |
Correct |
3 ms |
912 KB |
Output is correct |
24 |
Correct |
4 ms |
972 KB |
Output is correct |
25 |
Correct |
6 ms |
992 KB |
Output is correct |
26 |
Correct |
7 ms |
996 KB |
Output is correct |
27 |
Correct |
6 ms |
1020 KB |
Output is correct |
28 |
Correct |
7 ms |
1024 KB |
Output is correct |
29 |
Correct |
6 ms |
1024 KB |
Output is correct |
30 |
Correct |
4 ms |
1024 KB |
Output is correct |
31 |
Correct |
5 ms |
1032 KB |
Output is correct |
32 |
Correct |
4 ms |
1036 KB |
Output is correct |
33 |
Correct |
5 ms |
1040 KB |
Output is correct |
34 |
Correct |
6 ms |
1044 KB |
Output is correct |
35 |
Correct |
6 ms |
1044 KB |
Output is correct |
36 |
Correct |
4 ms |
1044 KB |
Output is correct |
37 |
Correct |
15 ms |
1312 KB |
Output is correct |
38 |
Correct |
17 ms |
1316 KB |
Output is correct |
39 |
Correct |
54 ms |
1704 KB |
Output is correct |
40 |
Correct |
31 ms |
1704 KB |
Output is correct |
41 |
Correct |
65 ms |
1856 KB |
Output is correct |
42 |
Correct |
27 ms |
1856 KB |
Output is correct |
43 |
Correct |
47 ms |
1908 KB |
Output is correct |
44 |
Correct |
50 ms |
1996 KB |
Output is correct |
45 |
Correct |
49 ms |
2132 KB |
Output is correct |
46 |
Correct |
36 ms |
2132 KB |
Output is correct |
47 |
Correct |
29 ms |
2132 KB |
Output is correct |
48 |
Correct |
60 ms |
2132 KB |
Output is correct |
49 |
Correct |
59 ms |
2132 KB |
Output is correct |
50 |
Correct |
30 ms |
2132 KB |
Output is correct |
51 |
Correct |
6 ms |
2132 KB |
Output is correct |
52 |
Correct |
65 ms |
2156 KB |
Output is correct |
53 |
Correct |
47 ms |
2156 KB |
Output is correct |
54 |
Correct |
66 ms |
2156 KB |
Output is correct |
55 |
Correct |
130 ms |
2936 KB |
Output is correct |
56 |
Correct |
58 ms |
2936 KB |
Output is correct |
57 |
Correct |
137 ms |
3072 KB |
Output is correct |
58 |
Correct |
73 ms |
3072 KB |
Output is correct |
59 |
Correct |
92 ms |
3072 KB |
Output is correct |
60 |
Correct |
11 ms |
3072 KB |
Output is correct |
61 |
Correct |
98 ms |
3072 KB |
Output is correct |
62 |
Correct |
102 ms |
3072 KB |
Output is correct |
63 |
Correct |
109 ms |
3072 KB |
Output is correct |
64 |
Correct |
106 ms |
3072 KB |
Output is correct |
65 |
Correct |
59 ms |
3072 KB |
Output is correct |
66 |
Correct |
69 ms |
3072 KB |
Output is correct |
67 |
Correct |
106 ms |
3072 KB |
Output is correct |
68 |
Correct |
27 ms |
3072 KB |
Output is correct |
69 |
Correct |
352 ms |
4784 KB |
Output is correct |
70 |
Correct |
212 ms |
4784 KB |
Output is correct |
71 |
Correct |
203 ms |
4784 KB |
Output is correct |
72 |
Correct |
199 ms |
4784 KB |
Output is correct |
73 |
Correct |
192 ms |
4784 KB |
Output is correct |
74 |
Correct |
372 ms |
4952 KB |
Output is correct |
75 |
Correct |
286 ms |
4952 KB |
Output is correct |
76 |
Correct |
408 ms |
5192 KB |
Output is correct |
77 |
Correct |
391 ms |
5200 KB |
Output is correct |