Submission #236477

# Submission time Handle Problem Language Result Execution time Memory
236477 2020-06-02T11:18:01 Z maskoff Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 109176 KB
#include <bits/stdc++.h>
#include <ext/rope>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
 
#define file ""
 
#define all(x) x.begin(), x.end()
 
#define sc second
#define fr first
 
#define pb push_back
#define mp make_pair
 
#define pss pair<line*, line*>
 
using namespace std;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
                                 
const ll inf = 1e18;
const int MOD = 1e9 + 7;
 
const int dx[] = {-1, +1, -2, +2, -2, +2, -1, +1};
const int dy[] = {-2, -2, -1, -1, +1, +1, +2, +2};
 
int const N = 5e3 + 5;
int const M = 2e6;

int main() {                 
#ifdef Mask                                                         
  freopen(".in", 	"r", stdin);
  freopen(".out", "w", stdout);  
#endif
	ios_base :: sync_with_stdio(false);               
  cin.tie(nullptr);
  int n;
  cin >> n;
  int sum = 0;
  int a[n + 1];
  for (int i = 1; i <= n; i++)
  	cin >> a[i], sum += a[i];
  int d[n + 1][sum + 100001];
  for (int i = 1; i <= n; i++)
  	for (int j = 0; j <= sum + 100000; j++)
  		d[i][j] = 0;

  for (int del = 0; del <= n; del++) {
  	int dp[n + 1][sum + 1];
  	
  	for (int i = 0; i <= n; i++)
  		for (int w = 0; w <= sum; w++)
  			dp[i][w] = 0;

  	dp[0][0] = 1;
   	
   	for (int i = 0; i < n; i++) {
   	 	for (int w = 0; w <= sum; w++) 
   	 		dp[i + 1][w] |= dp[i][w];

   	 	if (i + 1 == del)
   	 		continue;

   	 	for (int w = 0; w <= sum; w++) 
   	 		if (a[i + 1] + w <= sum)
   	 			dp[i + 1][w + a[i + 1]] |= dp[i][w];
   	}
   	for (int w = 0; w <= sum; w++)
   		if (dp[n][w] == 1)
   			d[del][w] = 1;	
  }

  vector<int> ans;
  for (int k = 1; k <= 50000; k++)  {
  	int ok = true;
  	for (int del = 0; del <= n; del++) {
  		int all = sum + k;
  		if (del == 0) all -= k;
  		else all -= a[del];
  		if (all % 2 == 1) {
  			ok = false;
  			break;
  		}
  		int need = all / 2;
  		if (d[del][need] == 0) {
  			ok = false;
  			break;
  		}
  	}
  	if (ok == true)
  		ans.pb(k);
  }
 	cout << ans.size() << endl;
 	for (int to : ans)
 		cout << to << " ";      
	return 0;
 
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1920 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 5 ms 1920 KB Output is correct
5 Correct 8 ms 5120 KB Output is correct
6 Correct 6 ms 3456 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1920 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 5 ms 1920 KB Output is correct
5 Correct 8 ms 5120 KB Output is correct
6 Correct 6 ms 3456 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4224 KB Output is correct
10 Correct 12 ms 12160 KB Output is correct
11 Correct 11 ms 12160 KB Output is correct
12 Correct 12 ms 12160 KB Output is correct
13 Correct 10 ms 10496 KB Output is correct
14 Correct 11 ms 11392 KB Output is correct
15 Correct 11 ms 11392 KB Output is correct
16 Correct 11 ms 12160 KB Output is correct
17 Correct 8 ms 7424 KB Output is correct
18 Correct 10 ms 9856 KB Output is correct
19 Correct 11 ms 10496 KB Output is correct
20 Correct 12 ms 12160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1920 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 5 ms 1920 KB Output is correct
5 Correct 8 ms 5120 KB Output is correct
6 Correct 6 ms 3456 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4224 KB Output is correct
10 Correct 12 ms 12160 KB Output is correct
11 Correct 11 ms 12160 KB Output is correct
12 Correct 12 ms 12160 KB Output is correct
13 Correct 10 ms 10496 KB Output is correct
14 Correct 11 ms 11392 KB Output is correct
15 Correct 11 ms 11392 KB Output is correct
16 Correct 11 ms 12160 KB Output is correct
17 Correct 8 ms 7424 KB Output is correct
18 Correct 10 ms 9856 KB Output is correct
19 Correct 11 ms 10496 KB Output is correct
20 Correct 12 ms 12160 KB Output is correct
21 Correct 41 ms 27008 KB Output is correct
22 Correct 59 ms 31352 KB Output is correct
23 Correct 27 ms 20864 KB Output is correct
24 Correct 106 ms 40596 KB Output is correct
25 Correct 172 ms 43820 KB Output is correct
26 Correct 199 ms 47096 KB Output is correct
27 Correct 204 ms 46464 KB Output is correct
28 Correct 194 ms 46976 KB Output is correct
29 Correct 200 ms 47104 KB Output is correct
30 Correct 123 ms 43648 KB Output is correct
31 Correct 167 ms 45436 KB Output is correct
32 Correct 113 ms 43264 KB Output is correct
33 Correct 205 ms 47428 KB Output is correct
34 Correct 202 ms 47352 KB Output is correct
35 Correct 207 ms 47224 KB Output is correct
36 Correct 114 ms 43192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1920 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 5 ms 1920 KB Output is correct
5 Correct 8 ms 5120 KB Output is correct
6 Correct 6 ms 3456 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4224 KB Output is correct
10 Correct 12 ms 12160 KB Output is correct
11 Correct 11 ms 12160 KB Output is correct
12 Correct 12 ms 12160 KB Output is correct
13 Correct 10 ms 10496 KB Output is correct
14 Correct 11 ms 11392 KB Output is correct
15 Correct 11 ms 11392 KB Output is correct
16 Correct 11 ms 12160 KB Output is correct
17 Correct 8 ms 7424 KB Output is correct
18 Correct 10 ms 9856 KB Output is correct
19 Correct 11 ms 10496 KB Output is correct
20 Correct 12 ms 12160 KB Output is correct
21 Correct 41 ms 27008 KB Output is correct
22 Correct 59 ms 31352 KB Output is correct
23 Correct 27 ms 20864 KB Output is correct
24 Correct 106 ms 40596 KB Output is correct
25 Correct 172 ms 43820 KB Output is correct
26 Correct 199 ms 47096 KB Output is correct
27 Correct 204 ms 46464 KB Output is correct
28 Correct 194 ms 46976 KB Output is correct
29 Correct 200 ms 47104 KB Output is correct
30 Correct 123 ms 43648 KB Output is correct
31 Correct 167 ms 45436 KB Output is correct
32 Correct 113 ms 43264 KB Output is correct
33 Correct 205 ms 47428 KB Output is correct
34 Correct 202 ms 47352 KB Output is correct
35 Correct 207 ms 47224 KB Output is correct
36 Correct 114 ms 43192 KB Output is correct
37 Execution timed out 1103 ms 109176 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1920 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 5 ms 1920 KB Output is correct
5 Correct 8 ms 5120 KB Output is correct
6 Correct 6 ms 3456 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4224 KB Output is correct
10 Correct 12 ms 12160 KB Output is correct
11 Correct 11 ms 12160 KB Output is correct
12 Correct 12 ms 12160 KB Output is correct
13 Correct 10 ms 10496 KB Output is correct
14 Correct 11 ms 11392 KB Output is correct
15 Correct 11 ms 11392 KB Output is correct
16 Correct 11 ms 12160 KB Output is correct
17 Correct 8 ms 7424 KB Output is correct
18 Correct 10 ms 9856 KB Output is correct
19 Correct 11 ms 10496 KB Output is correct
20 Correct 12 ms 12160 KB Output is correct
21 Correct 41 ms 27008 KB Output is correct
22 Correct 59 ms 31352 KB Output is correct
23 Correct 27 ms 20864 KB Output is correct
24 Correct 106 ms 40596 KB Output is correct
25 Correct 172 ms 43820 KB Output is correct
26 Correct 199 ms 47096 KB Output is correct
27 Correct 204 ms 46464 KB Output is correct
28 Correct 194 ms 46976 KB Output is correct
29 Correct 200 ms 47104 KB Output is correct
30 Correct 123 ms 43648 KB Output is correct
31 Correct 167 ms 45436 KB Output is correct
32 Correct 113 ms 43264 KB Output is correct
33 Correct 205 ms 47428 KB Output is correct
34 Correct 202 ms 47352 KB Output is correct
35 Correct 207 ms 47224 KB Output is correct
36 Correct 114 ms 43192 KB Output is correct
37 Execution timed out 1103 ms 109176 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1920 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 5 ms 1920 KB Output is correct
5 Correct 8 ms 5120 KB Output is correct
6 Correct 6 ms 3456 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4224 KB Output is correct
10 Correct 12 ms 12160 KB Output is correct
11 Correct 11 ms 12160 KB Output is correct
12 Correct 12 ms 12160 KB Output is correct
13 Correct 10 ms 10496 KB Output is correct
14 Correct 11 ms 11392 KB Output is correct
15 Correct 11 ms 11392 KB Output is correct
16 Correct 11 ms 12160 KB Output is correct
17 Correct 8 ms 7424 KB Output is correct
18 Correct 10 ms 9856 KB Output is correct
19 Correct 11 ms 10496 KB Output is correct
20 Correct 12 ms 12160 KB Output is correct
21 Correct 41 ms 27008 KB Output is correct
22 Correct 59 ms 31352 KB Output is correct
23 Correct 27 ms 20864 KB Output is correct
24 Correct 106 ms 40596 KB Output is correct
25 Correct 172 ms 43820 KB Output is correct
26 Correct 199 ms 47096 KB Output is correct
27 Correct 204 ms 46464 KB Output is correct
28 Correct 194 ms 46976 KB Output is correct
29 Correct 200 ms 47104 KB Output is correct
30 Correct 123 ms 43648 KB Output is correct
31 Correct 167 ms 45436 KB Output is correct
32 Correct 113 ms 43264 KB Output is correct
33 Correct 205 ms 47428 KB Output is correct
34 Correct 202 ms 47352 KB Output is correct
35 Correct 207 ms 47224 KB Output is correct
36 Correct 114 ms 43192 KB Output is correct
37 Execution timed out 1103 ms 109176 KB Time limit exceeded
38 Halted 0 ms 0 KB -