답안 #523840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523840 2022-02-08T09:17:03 Z Bill_00 Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 744 KB
#include<bits/stdc++.h>
#define N 1000005
typedef long long ll;

using namespace std;

int a[N];
int n;
int sum;
bitset<500000> BS, ans, g;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for(int i = 1; i <= 250000; i++){
		ans[i] = 1;
	}
	int n;
	cin >> n;

	BS[0] = 1;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
		BS = BS | (BS << a[i]);
	}

	if(sum % 2 == 0){
		int k = sum >> 1;
		if(BS[k] == 0){
			cout << 0;
			return 0;
		}
	}
	else{
		cout << 0;
		return 0;
	}

	for(int i = 1; i <= n; i++){
		BS.reset();
		g.reset();
		sum = 0;
		BS[0] = 1;
		for(int j = 1; j <= n; j++){
			if(i != j){
				BS = BS | (BS << a[j]);
				sum += a[j];
			}
		}
		int k = BS._Find_first();
		while(k < sum){
			g[abs(sum - 2 * k)] = 1;
			BS[k] = 0;
			k = BS._Find_first();
		}
		ans &= g;
	}
	vector<int> anss;
	for(int i = 1; i <= 250000; i++){
		if(ans[i] == 1){
			anss.push_back(i);
		}
	}
	cout << anss.size() << '\n';
	for(int value : anss) cout << value << ' ';



	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 4 ms 608 KB Output is correct
6 Correct 4 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 4 ms 608 KB Output is correct
6 Correct 4 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 20 ms 716 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 19 ms 588 KB Output is correct
13 Correct 14 ms 584 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 17 ms 584 KB Output is correct
16 Correct 19 ms 608 KB Output is correct
17 Correct 8 ms 604 KB Output is correct
18 Correct 12 ms 608 KB Output is correct
19 Correct 14 ms 588 KB Output is correct
20 Correct 18 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 4 ms 608 KB Output is correct
6 Correct 4 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 20 ms 716 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 19 ms 588 KB Output is correct
13 Correct 14 ms 584 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 17 ms 584 KB Output is correct
16 Correct 19 ms 608 KB Output is correct
17 Correct 8 ms 604 KB Output is correct
18 Correct 12 ms 608 KB Output is correct
19 Correct 14 ms 588 KB Output is correct
20 Correct 18 ms 632 KB Output is correct
21 Correct 91 ms 608 KB Output is correct
22 Correct 115 ms 612 KB Output is correct
23 Correct 50 ms 588 KB Output is correct
24 Correct 171 ms 608 KB Output is correct
25 Correct 211 ms 612 KB Output is correct
26 Correct 222 ms 612 KB Output is correct
27 Correct 208 ms 604 KB Output is correct
28 Correct 229 ms 608 KB Output is correct
29 Correct 213 ms 608 KB Output is correct
30 Correct 203 ms 588 KB Output is correct
31 Correct 229 ms 612 KB Output is correct
32 Correct 206 ms 708 KB Output is correct
33 Correct 195 ms 588 KB Output is correct
34 Correct 216 ms 608 KB Output is correct
35 Correct 222 ms 612 KB Output is correct
36 Correct 196 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 4 ms 608 KB Output is correct
6 Correct 4 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 20 ms 716 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 19 ms 588 KB Output is correct
13 Correct 14 ms 584 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 17 ms 584 KB Output is correct
16 Correct 19 ms 608 KB Output is correct
17 Correct 8 ms 604 KB Output is correct
18 Correct 12 ms 608 KB Output is correct
19 Correct 14 ms 588 KB Output is correct
20 Correct 18 ms 632 KB Output is correct
21 Correct 91 ms 608 KB Output is correct
22 Correct 115 ms 612 KB Output is correct
23 Correct 50 ms 588 KB Output is correct
24 Correct 171 ms 608 KB Output is correct
25 Correct 211 ms 612 KB Output is correct
26 Correct 222 ms 612 KB Output is correct
27 Correct 208 ms 604 KB Output is correct
28 Correct 229 ms 608 KB Output is correct
29 Correct 213 ms 608 KB Output is correct
30 Correct 203 ms 588 KB Output is correct
31 Correct 229 ms 612 KB Output is correct
32 Correct 206 ms 708 KB Output is correct
33 Correct 195 ms 588 KB Output is correct
34 Correct 216 ms 608 KB Output is correct
35 Correct 222 ms 612 KB Output is correct
36 Correct 196 ms 588 KB Output is correct
37 Execution timed out 1037 ms 744 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 4 ms 608 KB Output is correct
6 Correct 4 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 20 ms 716 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 19 ms 588 KB Output is correct
13 Correct 14 ms 584 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 17 ms 584 KB Output is correct
16 Correct 19 ms 608 KB Output is correct
17 Correct 8 ms 604 KB Output is correct
18 Correct 12 ms 608 KB Output is correct
19 Correct 14 ms 588 KB Output is correct
20 Correct 18 ms 632 KB Output is correct
21 Correct 91 ms 608 KB Output is correct
22 Correct 115 ms 612 KB Output is correct
23 Correct 50 ms 588 KB Output is correct
24 Correct 171 ms 608 KB Output is correct
25 Correct 211 ms 612 KB Output is correct
26 Correct 222 ms 612 KB Output is correct
27 Correct 208 ms 604 KB Output is correct
28 Correct 229 ms 608 KB Output is correct
29 Correct 213 ms 608 KB Output is correct
30 Correct 203 ms 588 KB Output is correct
31 Correct 229 ms 612 KB Output is correct
32 Correct 206 ms 708 KB Output is correct
33 Correct 195 ms 588 KB Output is correct
34 Correct 216 ms 608 KB Output is correct
35 Correct 222 ms 612 KB Output is correct
36 Correct 196 ms 588 KB Output is correct
37 Execution timed out 1037 ms 744 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 4 ms 608 KB Output is correct
6 Correct 4 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 20 ms 716 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 19 ms 588 KB Output is correct
13 Correct 14 ms 584 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 17 ms 584 KB Output is correct
16 Correct 19 ms 608 KB Output is correct
17 Correct 8 ms 604 KB Output is correct
18 Correct 12 ms 608 KB Output is correct
19 Correct 14 ms 588 KB Output is correct
20 Correct 18 ms 632 KB Output is correct
21 Correct 91 ms 608 KB Output is correct
22 Correct 115 ms 612 KB Output is correct
23 Correct 50 ms 588 KB Output is correct
24 Correct 171 ms 608 KB Output is correct
25 Correct 211 ms 612 KB Output is correct
26 Correct 222 ms 612 KB Output is correct
27 Correct 208 ms 604 KB Output is correct
28 Correct 229 ms 608 KB Output is correct
29 Correct 213 ms 608 KB Output is correct
30 Correct 203 ms 588 KB Output is correct
31 Correct 229 ms 612 KB Output is correct
32 Correct 206 ms 708 KB Output is correct
33 Correct 195 ms 588 KB Output is correct
34 Correct 216 ms 608 KB Output is correct
35 Correct 222 ms 612 KB Output is correct
36 Correct 196 ms 588 KB Output is correct
37 Execution timed out 1037 ms 744 KB Time limit exceeded
38 Halted 0 ms 0 KB -