Submission #91474

# Submission time Handle Problem Language Result Execution time Memory
91474 2018-12-27T16:26:01 Z davitmarg Bootfall (IZhO17_bootfall) C++17
13 / 100
3 ms 772 KB
/*
DEATH-MATCH
Davit-Marg
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>  
#include <fstream>  
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
using namespace std;

LL n,a[5000006],cant[5000006];
LL sum,sm;
vector<LL> ans;
LL dp[5000006];

void add(LL k)
{
	sum += k;
	for (LL j = sm; j >= 0; j--)
		dp[j + k] += dp[j];
}

void rem(LL k)
{
	sum -= k;
	for (LL i = 0; i <= sm; i++)
		dp[i + k] -= dp[i];
}

int main()
{
	cin >> n;
	for (LL i = 0; i < n; i++)
	{
		cin >> a[i];
		sm += a[i];
	}
	dp[0] = 1ll;

	for (LL i = 0; i < n; i++)
		add(a[i]);

	if (sm % 2==1 || dp[sm / 2] == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	for (LL i = 0; i < n; i++)
	{
		rem(a[i]);
		for (LL j = 0; j <= sm; j++)
			if ((sum+j) % 2==1 || dp[(sum+j) / 2] <= 0)
				cant[j] = 1;
		add(a[i]);
	}
	for (LL j = 0; j <= sm; j++)
		if (!cant[j])
			ans.PB(j);
	
	cout << ans.size() << endl;
	if (ans.size() == 0)
		return 0;
	for (LL i = 0; i < ans.size(); i++)
		cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:79:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (LL i = 0; i < ans.size(); i++)
                 ~~^~~~~~~~~~~~
# 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 408 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 772 KB Output is correct
9 Correct 2 ms 772 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 408 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 772 KB Output is correct
9 Correct 2 ms 772 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 772 KB Output is correct
12 Correct 2 ms 772 KB Output is correct
13 Correct 2 ms 772 KB Output is correct
14 Correct 2 ms 772 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 772 KB Output is correct
17 Correct 2 ms 772 KB Output is correct
18 Correct 2 ms 772 KB Output is correct
19 Correct 2 ms 772 KB Output is correct
20 Correct 2 ms 772 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 408 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 772 KB Output is correct
9 Correct 2 ms 772 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 772 KB Output is correct
12 Correct 2 ms 772 KB Output is correct
13 Correct 2 ms 772 KB Output is correct
14 Correct 2 ms 772 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 772 KB Output is correct
17 Correct 2 ms 772 KB Output is correct
18 Correct 2 ms 772 KB Output is correct
19 Correct 2 ms 772 KB Output is correct
20 Correct 2 ms 772 KB Output is correct
21 Correct 3 ms 772 KB Output is correct
22 Incorrect 3 ms 772 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 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 408 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 772 KB Output is correct
9 Correct 2 ms 772 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 772 KB Output is correct
12 Correct 2 ms 772 KB Output is correct
13 Correct 2 ms 772 KB Output is correct
14 Correct 2 ms 772 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 772 KB Output is correct
17 Correct 2 ms 772 KB Output is correct
18 Correct 2 ms 772 KB Output is correct
19 Correct 2 ms 772 KB Output is correct
20 Correct 2 ms 772 KB Output is correct
21 Correct 3 ms 772 KB Output is correct
22 Incorrect 3 ms 772 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 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 408 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 772 KB Output is correct
9 Correct 2 ms 772 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 772 KB Output is correct
12 Correct 2 ms 772 KB Output is correct
13 Correct 2 ms 772 KB Output is correct
14 Correct 2 ms 772 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 772 KB Output is correct
17 Correct 2 ms 772 KB Output is correct
18 Correct 2 ms 772 KB Output is correct
19 Correct 2 ms 772 KB Output is correct
20 Correct 2 ms 772 KB Output is correct
21 Correct 3 ms 772 KB Output is correct
22 Incorrect 3 ms 772 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 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 408 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 772 KB Output is correct
9 Correct 2 ms 772 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 772 KB Output is correct
12 Correct 2 ms 772 KB Output is correct
13 Correct 2 ms 772 KB Output is correct
14 Correct 2 ms 772 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 772 KB Output is correct
17 Correct 2 ms 772 KB Output is correct
18 Correct 2 ms 772 KB Output is correct
19 Correct 2 ms 772 KB Output is correct
20 Correct 2 ms 772 KB Output is correct
21 Correct 3 ms 772 KB Output is correct
22 Incorrect 3 ms 772 KB Output isn't correct
23 Halted 0 ms 0 KB -