Submission #771133

# Submission time Handle Problem Language Result Execution time Memory
771133 2023-07-02T13:25:44 Z OrazB Bootfall (IZhO17_bootfall) C++17
100 / 100
287 ms 3448 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
//Dijkstra->set
//set.find_by_order(x) x-position value
//set.order_of_key(x) number of strictly less elements don't need *set.??
#define N 100005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second

int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int>a(n+1,0);
	int S=0;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		S += a[i];
	}
	vector<int> dp(S+1,0), can(S+1,0);
	dp[0]=1;
	for (int i = 1; i <= n; i++){
		for (int j = S-a[i]; j >= 0; j--){
			dp[j+a[i]] += dp[j];
		}
	}
	if (S%2 or !dp[S/2]) return cout << 0, 0;
	for (int i = 1; i <= n; i++){
		for (int j = a[i]; j <= S; j++){
			dp[j] -= dp[j-a[i]];
		}
		int newS = S-a[i];
		for (int j = 0; j <= newS/2; j++){
			if (dp[j]) can[newS-2*j]++;
		}
		for (int j = S-a[i]; j >= 0; j--){
			dp[j+a[i]] += dp[j];
		}
	}
	vector<int> ans;
	for (int i = 1; i <= S; i++){
		if (can[i] == n) ans.pb(i);
	}
	cout << ans.size() << '\n';
	for (auto i : ans){
		cout << i << " ";
	}
}	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 0 ms 324 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 0 ms 324 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 316 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 320 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 2 ms 320 KB Output is correct
31 Correct 2 ms 320 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 2 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 0 ms 324 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 316 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 320 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 2 ms 320 KB Output is correct
31 Correct 2 ms 320 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 2 ms 320 KB Output is correct
37 Correct 10 ms 708 KB Output is correct
38 Correct 10 ms 600 KB Output is correct
39 Correct 42 ms 800 KB Output is correct
40 Correct 20 ms 700 KB Output is correct
41 Correct 42 ms 888 KB Output is correct
42 Correct 17 ms 724 KB Output is correct
43 Correct 31 ms 1008 KB Output is correct
44 Correct 32 ms 1020 KB Output is correct
45 Correct 32 ms 1028 KB Output is correct
46 Correct 19 ms 468 KB Output is correct
47 Correct 19 ms 724 KB Output is correct
48 Correct 35 ms 1068 KB Output is correct
49 Correct 35 ms 812 KB Output is correct
50 Correct 19 ms 704 KB Output is correct
51 Correct 5 ms 468 KB Output is correct
52 Correct 43 ms 1284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 0 ms 324 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 316 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 320 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 2 ms 320 KB Output is correct
31 Correct 2 ms 320 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 2 ms 320 KB Output is correct
37 Correct 10 ms 708 KB Output is correct
38 Correct 10 ms 600 KB Output is correct
39 Correct 42 ms 800 KB Output is correct
40 Correct 20 ms 700 KB Output is correct
41 Correct 42 ms 888 KB Output is correct
42 Correct 17 ms 724 KB Output is correct
43 Correct 31 ms 1008 KB Output is correct
44 Correct 32 ms 1020 KB Output is correct
45 Correct 32 ms 1028 KB Output is correct
46 Correct 19 ms 468 KB Output is correct
47 Correct 19 ms 724 KB Output is correct
48 Correct 35 ms 1068 KB Output is correct
49 Correct 35 ms 812 KB Output is correct
50 Correct 19 ms 704 KB Output is correct
51 Correct 5 ms 468 KB Output is correct
52 Correct 43 ms 1284 KB Output is correct
53 Correct 33 ms 928 KB Output is correct
54 Correct 50 ms 1148 KB Output is correct
55 Correct 88 ms 1712 KB Output is correct
56 Correct 38 ms 1100 KB Output is correct
57 Correct 89 ms 1872 KB Output is correct
58 Correct 47 ms 1100 KB Output is correct
59 Correct 59 ms 1316 KB Output is correct
60 Correct 14 ms 724 KB Output is correct
61 Correct 67 ms 1508 KB Output is correct
62 Correct 68 ms 1592 KB Output is correct
63 Correct 77 ms 1720 KB Output is correct
64 Correct 70 ms 1624 KB Output is correct
65 Correct 33 ms 692 KB Output is correct
66 Correct 36 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 0 ms 324 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 316 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 320 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 2 ms 320 KB Output is correct
31 Correct 2 ms 320 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 2 ms 320 KB Output is correct
37 Correct 10 ms 708 KB Output is correct
38 Correct 10 ms 600 KB Output is correct
39 Correct 42 ms 800 KB Output is correct
40 Correct 20 ms 700 KB Output is correct
41 Correct 42 ms 888 KB Output is correct
42 Correct 17 ms 724 KB Output is correct
43 Correct 31 ms 1008 KB Output is correct
44 Correct 32 ms 1020 KB Output is correct
45 Correct 32 ms 1028 KB Output is correct
46 Correct 19 ms 468 KB Output is correct
47 Correct 19 ms 724 KB Output is correct
48 Correct 35 ms 1068 KB Output is correct
49 Correct 35 ms 812 KB Output is correct
50 Correct 19 ms 704 KB Output is correct
51 Correct 5 ms 468 KB Output is correct
52 Correct 43 ms 1284 KB Output is correct
53 Correct 33 ms 928 KB Output is correct
54 Correct 50 ms 1148 KB Output is correct
55 Correct 88 ms 1712 KB Output is correct
56 Correct 38 ms 1100 KB Output is correct
57 Correct 89 ms 1872 KB Output is correct
58 Correct 47 ms 1100 KB Output is correct
59 Correct 59 ms 1316 KB Output is correct
60 Correct 14 ms 724 KB Output is correct
61 Correct 67 ms 1508 KB Output is correct
62 Correct 68 ms 1592 KB Output is correct
63 Correct 77 ms 1720 KB Output is correct
64 Correct 70 ms 1624 KB Output is correct
65 Correct 33 ms 692 KB Output is correct
66 Correct 36 ms 728 KB Output is correct
67 Correct 79 ms 1460 KB Output is correct
68 Correct 38 ms 1236 KB Output is correct
69 Correct 234 ms 3124 KB Output is correct
70 Correct 138 ms 1996 KB Output is correct
71 Correct 134 ms 1924 KB Output is correct
72 Correct 142 ms 1216 KB Output is correct
73 Correct 141 ms 1236 KB Output is correct
74 Correct 245 ms 3216 KB Output is correct
75 Correct 220 ms 2704 KB Output is correct
76 Correct 287 ms 3380 KB Output is correct
77 Correct 259 ms 3448 KB Output is correct