Submission #92297

# Submission time Handle Problem Language Result Execution time Memory
92297 2019-01-02T12:30:21 Z Nordway Bootfall (IZhO17_bootfall) C++14
100 / 100
385 ms 3932 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const int inf = INT_MAX;
const int mod = 998244353;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int N = 505;
const int M = 1e2+1;

int a[N],p[N*N],sum,b[N*N],cnt[N*N];

void add(int x){
	for(int i=sum;i>=0;i--){
		if(i>=x)p[i]+=p[i-x];
	}
}

void del(int x){
	for(int i=0;i<=sum;i++)b[i]=p[i];
	for(int i=0;i<=sum;i++){
		if(i>=x)b[i]-=b[i-x];
	}
}

int main(){
	boost;
	int n;
	cin>>n;
	p[0]=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
		add(a[i]);
	}
	if(sum%2||p[sum/2]==0){
		cout<<0;
		return 0;
	}
	for(int i=1;i<=n;i++){
		del(a[i]);
		for(int j=sum;j>=0;j--){
			if(b[j]){
				int val=sum-2*j-a[i];
				//cout<<val<<" ";
				if(val>0)cnt[val]++;
			}
		}
	}
	int ans=0;
	for(int i=0;i<=sum;i++){
		if(cnt[i]==n)ans++;
	}
	cout<<ans<<endl;
	for(int i=0;i<=sum;i++){
		if(cnt[i]==n)cout<<i<<" ";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 0 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 0 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 0 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 5 ms 504 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 7 ms 504 KB Output is correct
36 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 0 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 5 ms 504 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 7 ms 504 KB Output is correct
36 Correct 4 ms 376 KB Output is correct
37 Correct 13 ms 632 KB Output is correct
38 Correct 14 ms 632 KB Output is correct
39 Correct 45 ms 1144 KB Output is correct
40 Correct 27 ms 888 KB Output is correct
41 Correct 56 ms 1276 KB Output is correct
42 Correct 24 ms 760 KB Output is correct
43 Correct 48 ms 1272 KB Output is correct
44 Correct 44 ms 1144 KB Output is correct
45 Correct 45 ms 1144 KB Output is correct
46 Correct 28 ms 760 KB Output is correct
47 Correct 26 ms 888 KB Output is correct
48 Correct 57 ms 1272 KB Output is correct
49 Correct 66 ms 1144 KB Output is correct
50 Correct 26 ms 768 KB Output is correct
51 Correct 6 ms 504 KB Output is correct
52 Correct 63 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 0 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 5 ms 504 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 7 ms 504 KB Output is correct
36 Correct 4 ms 376 KB Output is correct
37 Correct 13 ms 632 KB Output is correct
38 Correct 14 ms 632 KB Output is correct
39 Correct 45 ms 1144 KB Output is correct
40 Correct 27 ms 888 KB Output is correct
41 Correct 56 ms 1276 KB Output is correct
42 Correct 24 ms 760 KB Output is correct
43 Correct 48 ms 1272 KB Output is correct
44 Correct 44 ms 1144 KB Output is correct
45 Correct 45 ms 1144 KB Output is correct
46 Correct 28 ms 760 KB Output is correct
47 Correct 26 ms 888 KB Output is correct
48 Correct 57 ms 1272 KB Output is correct
49 Correct 66 ms 1144 KB Output is correct
50 Correct 26 ms 768 KB Output is correct
51 Correct 6 ms 504 KB Output is correct
52 Correct 63 ms 1400 KB Output is correct
53 Correct 44 ms 1016 KB Output is correct
54 Correct 58 ms 1144 KB Output is correct
55 Correct 129 ms 2040 KB Output is correct
56 Correct 51 ms 1144 KB Output is correct
57 Correct 137 ms 2012 KB Output is correct
58 Correct 64 ms 1272 KB Output is correct
59 Correct 79 ms 1424 KB Output is correct
60 Correct 14 ms 636 KB Output is correct
61 Correct 91 ms 1528 KB Output is correct
62 Correct 100 ms 1900 KB Output is correct
63 Correct 109 ms 1868 KB Output is correct
64 Correct 101 ms 1856 KB Output is correct
65 Correct 50 ms 896 KB Output is correct
66 Correct 70 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 0 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 5 ms 504 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 7 ms 504 KB Output is correct
36 Correct 4 ms 376 KB Output is correct
37 Correct 13 ms 632 KB Output is correct
38 Correct 14 ms 632 KB Output is correct
39 Correct 45 ms 1144 KB Output is correct
40 Correct 27 ms 888 KB Output is correct
41 Correct 56 ms 1276 KB Output is correct
42 Correct 24 ms 760 KB Output is correct
43 Correct 48 ms 1272 KB Output is correct
44 Correct 44 ms 1144 KB Output is correct
45 Correct 45 ms 1144 KB Output is correct
46 Correct 28 ms 760 KB Output is correct
47 Correct 26 ms 888 KB Output is correct
48 Correct 57 ms 1272 KB Output is correct
49 Correct 66 ms 1144 KB Output is correct
50 Correct 26 ms 768 KB Output is correct
51 Correct 6 ms 504 KB Output is correct
52 Correct 63 ms 1400 KB Output is correct
53 Correct 44 ms 1016 KB Output is correct
54 Correct 58 ms 1144 KB Output is correct
55 Correct 129 ms 2040 KB Output is correct
56 Correct 51 ms 1144 KB Output is correct
57 Correct 137 ms 2012 KB Output is correct
58 Correct 64 ms 1272 KB Output is correct
59 Correct 79 ms 1424 KB Output is correct
60 Correct 14 ms 636 KB Output is correct
61 Correct 91 ms 1528 KB Output is correct
62 Correct 100 ms 1900 KB Output is correct
63 Correct 109 ms 1868 KB Output is correct
64 Correct 101 ms 1856 KB Output is correct
65 Correct 50 ms 896 KB Output is correct
66 Correct 70 ms 1144 KB Output is correct
67 Correct 90 ms 1508 KB Output is correct
68 Correct 37 ms 888 KB Output is correct
69 Correct 345 ms 3576 KB Output is correct
70 Correct 200 ms 2424 KB Output is correct
71 Correct 178 ms 2168 KB Output is correct
72 Correct 181 ms 1912 KB Output is correct
73 Correct 176 ms 1916 KB Output is correct
74 Correct 341 ms 3660 KB Output is correct
75 Correct 256 ms 2976 KB Output is correct
76 Correct 385 ms 3932 KB Output is correct
77 Correct 364 ms 3832 KB Output is correct