Submission #344922

# Submission time Handle Problem Language Result Execution time Memory
344922 2021-01-06T18:26:37 Z _ani Bootfall (IZhO17_bootfall) C++17
0 / 100
1 ms 492 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 100;
int dp[N + 1][N + 1][N * N + 1];
vector<int> a;
int b[N];
vector<int> ans;
int sum;
int main()
{
	int n;
	cin >> n;
	a.resize(n);
	
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] = b[i];
		sum += a[i];
	}
	for (int i = 0; i < n; i++)
	{
		int jnj = b[i];
		a.erase(find(a.begin(), a.end(), jnj));
		for (int i = 0; i < n; i++)
			dp[jnj][i][a[i]] = dp[jnj][i][0] = 1;
		for (int i = 0; i < n - 1; i++)
			for (int j = 1; j <= N * N; j++)
				if (j >= a[i] && i >= 1)
					dp[jnj][i][j] = dp[jnj][i - 1][j - a[i]];
		a.push_back(jnj);
	}
	for (int i = 1; i <= N*N; i++)
	{
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if ((sum - b[j] + i) % 2 == 0) {
				int tmp = (sum - b[j] + i) / 2;
				for (int k = 0; k < n; k++)
					if (dp[a[j]][k][tmp]) {
						cnt++;
						break;
					}
			}
		}
		if (cnt == n)ans.push_back(i);
	}
	cout << ans.size() << '\n';
	for (int v : ans)
		cout << v << ' ';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -