Submission #314966

# Submission time Handle Problem Language Result Execution time Memory
314966 2020-10-21T18:09:47 Z shrek12357 Bootfall (IZhO17_bootfall) C++14
0 / 100
5 ms 384 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0); 

int main() {
	int n;
	cin >> n;
	vector<int> nums;
	bitset<250001> ans;
	ans.flip();
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		sum += temp;
		nums.push_back(temp);
	}
	for (int i = 0; i < n; i++) {
		bitset<250001> dp;
		dp[0] = 1;
		for (int j = 0; j < n; j++) {
			if (i == j) {
				continue;
			}
			dp |= (dp << nums[j]);
		}
		int curSum = sum - nums[i];
		for (int j = 0; j < 250001; j++) {
			if (2*j > curSum) {
				ans[j] = 0;
				continue;
			}
			ans[curSum - j - j] = ans[curSum - j - j] & dp[j];
		}
	}
	cout << ans.count() - 1 << endl;
	for (int i = 1; i < 250000; i++) {
		if (ans[i] == 1) {
			cout << i + 1 << endl;
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -