Submission #87077

# Submission time Handle Problem Language Result Execution time Memory
87077 2018-11-29T11:50:59 Z dimash241 Bootfall (IZhO17_bootfall) C++14
100 / 100
394 ms 5160 KB
# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N], sum;
ll dp[N];
int can[N];

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 () {
	SpeedForce;               
    cin >> n;
    dp[0] = 1;
    For (i, 1, n ) {
    	cin >> a[i];
    	add (a[i]);
    }

    if (sum & 1 || !dp[sum / 2]) {
    	cout << 0 << '\n';
    	exit(0);
    }
    For (i, 1, sum) can[i] = 1;

    For (i, 1, n) {
    	del(a[i]);
    	For (j, 1, sum + a[i]) {
    		if ((sum + j) % 2 != 0 || !dp[(sum + j) / 2]) { 
    			can[j] = 0;
    		}
    	}
    	add(a[i]);
    }

    vector < int > ans;
    For (i, 1, sum) if (can[i]) ans.pb(i);

   	cout << sz(ans) << '\n';
   	for (auto it : ans) cout << it << ' ';
    return Accepted;
}

// Coded By OB
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 528 KB Output is correct
5 Correct 3 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 528 KB Output is correct
5 Correct 3 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Correct 2 ms 624 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 2 ms 648 KB Output is correct
18 Correct 2 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 3 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 528 KB Output is correct
5 Correct 3 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Correct 2 ms 624 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 2 ms 648 KB Output is correct
18 Correct 2 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 3 ms 688 KB Output is correct
21 Correct 3 ms 692 KB Output is correct
22 Correct 3 ms 824 KB Output is correct
23 Correct 4 ms 824 KB Output is correct
24 Correct 4 ms 824 KB Output is correct
25 Correct 5 ms 888 KB Output is correct
26 Correct 8 ms 888 KB Output is correct
27 Correct 7 ms 1036 KB Output is correct
28 Correct 8 ms 1036 KB Output is correct
29 Correct 6 ms 1036 KB Output is correct
30 Correct 4 ms 1036 KB Output is correct
31 Correct 6 ms 1036 KB Output is correct
32 Correct 5 ms 1036 KB Output is correct
33 Correct 5 ms 1076 KB Output is correct
34 Correct 8 ms 1076 KB Output is correct
35 Correct 5 ms 1076 KB Output is correct
36 Correct 4 ms 1076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 528 KB Output is correct
5 Correct 3 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Correct 2 ms 624 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 2 ms 648 KB Output is correct
18 Correct 2 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 3 ms 688 KB Output is correct
21 Correct 3 ms 692 KB Output is correct
22 Correct 3 ms 824 KB Output is correct
23 Correct 4 ms 824 KB Output is correct
24 Correct 4 ms 824 KB Output is correct
25 Correct 5 ms 888 KB Output is correct
26 Correct 8 ms 888 KB Output is correct
27 Correct 7 ms 1036 KB Output is correct
28 Correct 8 ms 1036 KB Output is correct
29 Correct 6 ms 1036 KB Output is correct
30 Correct 4 ms 1036 KB Output is correct
31 Correct 6 ms 1036 KB Output is correct
32 Correct 5 ms 1036 KB Output is correct
33 Correct 5 ms 1076 KB Output is correct
34 Correct 8 ms 1076 KB Output is correct
35 Correct 5 ms 1076 KB Output is correct
36 Correct 4 ms 1076 KB Output is correct
37 Correct 15 ms 1204 KB Output is correct
38 Correct 19 ms 1336 KB Output is correct
39 Correct 50 ms 1460 KB Output is correct
40 Correct 33 ms 1460 KB Output is correct
41 Correct 66 ms 1976 KB Output is correct
42 Correct 29 ms 1976 KB Output is correct
43 Correct 57 ms 1976 KB Output is correct
44 Correct 51 ms 1976 KB Output is correct
45 Correct 48 ms 1976 KB Output is correct
46 Correct 32 ms 1976 KB Output is correct
47 Correct 29 ms 1976 KB Output is correct
48 Correct 51 ms 1976 KB Output is correct
49 Correct 54 ms 1976 KB Output is correct
50 Correct 30 ms 1976 KB Output is correct
51 Correct 5 ms 1976 KB Output is correct
52 Correct 90 ms 2208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 528 KB Output is correct
5 Correct 3 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Correct 2 ms 624 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 2 ms 648 KB Output is correct
18 Correct 2 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 3 ms 688 KB Output is correct
21 Correct 3 ms 692 KB Output is correct
22 Correct 3 ms 824 KB Output is correct
23 Correct 4 ms 824 KB Output is correct
24 Correct 4 ms 824 KB Output is correct
25 Correct 5 ms 888 KB Output is correct
26 Correct 8 ms 888 KB Output is correct
27 Correct 7 ms 1036 KB Output is correct
28 Correct 8 ms 1036 KB Output is correct
29 Correct 6 ms 1036 KB Output is correct
30 Correct 4 ms 1036 KB Output is correct
31 Correct 6 ms 1036 KB Output is correct
32 Correct 5 ms 1036 KB Output is correct
33 Correct 5 ms 1076 KB Output is correct
34 Correct 8 ms 1076 KB Output is correct
35 Correct 5 ms 1076 KB Output is correct
36 Correct 4 ms 1076 KB Output is correct
37 Correct 15 ms 1204 KB Output is correct
38 Correct 19 ms 1336 KB Output is correct
39 Correct 50 ms 1460 KB Output is correct
40 Correct 33 ms 1460 KB Output is correct
41 Correct 66 ms 1976 KB Output is correct
42 Correct 29 ms 1976 KB Output is correct
43 Correct 57 ms 1976 KB Output is correct
44 Correct 51 ms 1976 KB Output is correct
45 Correct 48 ms 1976 KB Output is correct
46 Correct 32 ms 1976 KB Output is correct
47 Correct 29 ms 1976 KB Output is correct
48 Correct 51 ms 1976 KB Output is correct
49 Correct 54 ms 1976 KB Output is correct
50 Correct 30 ms 1976 KB Output is correct
51 Correct 5 ms 1976 KB Output is correct
52 Correct 90 ms 2208 KB Output is correct
53 Correct 47 ms 2208 KB Output is correct
54 Correct 63 ms 2208 KB Output is correct
55 Correct 144 ms 2900 KB Output is correct
56 Correct 59 ms 2900 KB Output is correct
57 Correct 139 ms 3040 KB Output is correct
58 Correct 77 ms 3040 KB Output is correct
59 Correct 89 ms 3040 KB Output is correct
60 Correct 11 ms 3040 KB Output is correct
61 Correct 100 ms 3040 KB Output is correct
62 Correct 104 ms 3040 KB Output is correct
63 Correct 108 ms 3040 KB Output is correct
64 Correct 108 ms 3040 KB Output is correct
65 Correct 60 ms 3040 KB Output is correct
66 Correct 60 ms 3040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 528 KB Output is correct
5 Correct 3 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Correct 2 ms 624 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 2 ms 648 KB Output is correct
18 Correct 2 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 3 ms 688 KB Output is correct
21 Correct 3 ms 692 KB Output is correct
22 Correct 3 ms 824 KB Output is correct
23 Correct 4 ms 824 KB Output is correct
24 Correct 4 ms 824 KB Output is correct
25 Correct 5 ms 888 KB Output is correct
26 Correct 8 ms 888 KB Output is correct
27 Correct 7 ms 1036 KB Output is correct
28 Correct 8 ms 1036 KB Output is correct
29 Correct 6 ms 1036 KB Output is correct
30 Correct 4 ms 1036 KB Output is correct
31 Correct 6 ms 1036 KB Output is correct
32 Correct 5 ms 1036 KB Output is correct
33 Correct 5 ms 1076 KB Output is correct
34 Correct 8 ms 1076 KB Output is correct
35 Correct 5 ms 1076 KB Output is correct
36 Correct 4 ms 1076 KB Output is correct
37 Correct 15 ms 1204 KB Output is correct
38 Correct 19 ms 1336 KB Output is correct
39 Correct 50 ms 1460 KB Output is correct
40 Correct 33 ms 1460 KB Output is correct
41 Correct 66 ms 1976 KB Output is correct
42 Correct 29 ms 1976 KB Output is correct
43 Correct 57 ms 1976 KB Output is correct
44 Correct 51 ms 1976 KB Output is correct
45 Correct 48 ms 1976 KB Output is correct
46 Correct 32 ms 1976 KB Output is correct
47 Correct 29 ms 1976 KB Output is correct
48 Correct 51 ms 1976 KB Output is correct
49 Correct 54 ms 1976 KB Output is correct
50 Correct 30 ms 1976 KB Output is correct
51 Correct 5 ms 1976 KB Output is correct
52 Correct 90 ms 2208 KB Output is correct
53 Correct 47 ms 2208 KB Output is correct
54 Correct 63 ms 2208 KB Output is correct
55 Correct 144 ms 2900 KB Output is correct
56 Correct 59 ms 2900 KB Output is correct
57 Correct 139 ms 3040 KB Output is correct
58 Correct 77 ms 3040 KB Output is correct
59 Correct 89 ms 3040 KB Output is correct
60 Correct 11 ms 3040 KB Output is correct
61 Correct 100 ms 3040 KB Output is correct
62 Correct 104 ms 3040 KB Output is correct
63 Correct 108 ms 3040 KB Output is correct
64 Correct 108 ms 3040 KB Output is correct
65 Correct 60 ms 3040 KB Output is correct
66 Correct 60 ms 3040 KB Output is correct
67 Correct 108 ms 3040 KB Output is correct
68 Correct 26 ms 3040 KB Output is correct
69 Correct 372 ms 4744 KB Output is correct
70 Correct 218 ms 4744 KB Output is correct
71 Correct 209 ms 4744 KB Output is correct
72 Correct 198 ms 4744 KB Output is correct
73 Correct 209 ms 4744 KB Output is correct
74 Correct 384 ms 4928 KB Output is correct
75 Correct 287 ms 4928 KB Output is correct
76 Correct 394 ms 5116 KB Output is correct
77 Correct 384 ms 5160 KB Output is correct