Submission #236667

# Submission time Handle Problem Language Result Execution time Memory
236667 2020-06-02T19:06:05 Z maskoff Bootfall (IZhO17_bootfall) C++14
65 / 100
983 ms 8388 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 = 125001;
int const M = 2e6;

bitset<N> dp[505];

int main() {                 
#ifdef Mask                                                         
  freopen(".in", 	"r", stdin);
  freopen(".out", "w", stdout);  
#endif
	ios_base :: sync_with_stdio(false);               
  cin.tie(nullptr);
  cout.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];

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

  vector<int> ans;
  for (int k = 1; k <= 125000; k++)  {
  	bool 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 (need > N) {
  		 	ok = false;
  		 	break;
  		}
  			
  		if (dp[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 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 6 ms 640 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 6 ms 640 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
11 Correct 9 ms 896 KB Output is correct
12 Correct 9 ms 896 KB Output is correct
13 Correct 8 ms 768 KB Output is correct
14 Correct 9 ms 896 KB Output is correct
15 Correct 8 ms 768 KB Output is correct
16 Correct 9 ms 896 KB Output is correct
17 Correct 7 ms 640 KB Output is correct
18 Correct 8 ms 768 KB Output is correct
19 Correct 8 ms 768 KB Output is correct
20 Correct 9 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 6 ms 640 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
11 Correct 9 ms 896 KB Output is correct
12 Correct 9 ms 896 KB Output is correct
13 Correct 8 ms 768 KB Output is correct
14 Correct 9 ms 896 KB Output is correct
15 Correct 8 ms 768 KB Output is correct
16 Correct 9 ms 896 KB Output is correct
17 Correct 7 ms 640 KB Output is correct
18 Correct 8 ms 768 KB Output is correct
19 Correct 8 ms 768 KB Output is correct
20 Correct 9 ms 896 KB Output is correct
21 Correct 22 ms 1408 KB Output is correct
22 Correct 28 ms 1528 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 41 ms 1912 KB Output is correct
25 Correct 45 ms 1912 KB Output is correct
26 Correct 45 ms 1916 KB Output is correct
27 Correct 47 ms 1912 KB Output is correct
28 Correct 46 ms 1912 KB Output is correct
29 Correct 44 ms 1912 KB Output is correct
30 Correct 45 ms 1912 KB Output is correct
31 Correct 46 ms 2040 KB Output is correct
32 Correct 45 ms 2008 KB Output is correct
33 Correct 44 ms 1912 KB Output is correct
34 Correct 43 ms 1912 KB Output is correct
35 Correct 46 ms 1912 KB Output is correct
36 Correct 46 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 6 ms 640 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
11 Correct 9 ms 896 KB Output is correct
12 Correct 9 ms 896 KB Output is correct
13 Correct 8 ms 768 KB Output is correct
14 Correct 9 ms 896 KB Output is correct
15 Correct 8 ms 768 KB Output is correct
16 Correct 9 ms 896 KB Output is correct
17 Correct 7 ms 640 KB Output is correct
18 Correct 8 ms 768 KB Output is correct
19 Correct 8 ms 768 KB Output is correct
20 Correct 9 ms 896 KB Output is correct
21 Correct 22 ms 1408 KB Output is correct
22 Correct 28 ms 1528 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 41 ms 1912 KB Output is correct
25 Correct 45 ms 1912 KB Output is correct
26 Correct 45 ms 1916 KB Output is correct
27 Correct 47 ms 1912 KB Output is correct
28 Correct 46 ms 1912 KB Output is correct
29 Correct 44 ms 1912 KB Output is correct
30 Correct 45 ms 1912 KB Output is correct
31 Correct 46 ms 2040 KB Output is correct
32 Correct 45 ms 2008 KB Output is correct
33 Correct 44 ms 1912 KB Output is correct
34 Correct 43 ms 1912 KB Output is correct
35 Correct 46 ms 1912 KB Output is correct
36 Correct 46 ms 1912 KB Output is correct
37 Correct 167 ms 3576 KB Output is correct
38 Correct 173 ms 3580 KB Output is correct
39 Correct 239 ms 4216 KB Output is correct
40 Correct 301 ms 4856 KB Output is correct
41 Correct 284 ms 4600 KB Output is correct
42 Correct 261 ms 4440 KB Output is correct
43 Correct 258 ms 4472 KB Output is correct
44 Correct 257 ms 4600 KB Output is correct
45 Correct 267 ms 4600 KB Output is correct
46 Correct 289 ms 4472 KB Output is correct
47 Correct 259 ms 4600 KB Output is correct
48 Correct 263 ms 4600 KB Output is correct
49 Correct 243 ms 4344 KB Output is correct
50 Correct 263 ms 4472 KB Output is correct
51 Correct 245 ms 4216 KB Output is correct
52 Correct 310 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 6 ms 640 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
11 Correct 9 ms 896 KB Output is correct
12 Correct 9 ms 896 KB Output is correct
13 Correct 8 ms 768 KB Output is correct
14 Correct 9 ms 896 KB Output is correct
15 Correct 8 ms 768 KB Output is correct
16 Correct 9 ms 896 KB Output is correct
17 Correct 7 ms 640 KB Output is correct
18 Correct 8 ms 768 KB Output is correct
19 Correct 8 ms 768 KB Output is correct
20 Correct 9 ms 896 KB Output is correct
21 Correct 22 ms 1408 KB Output is correct
22 Correct 28 ms 1528 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 41 ms 1912 KB Output is correct
25 Correct 45 ms 1912 KB Output is correct
26 Correct 45 ms 1916 KB Output is correct
27 Correct 47 ms 1912 KB Output is correct
28 Correct 46 ms 1912 KB Output is correct
29 Correct 44 ms 1912 KB Output is correct
30 Correct 45 ms 1912 KB Output is correct
31 Correct 46 ms 2040 KB Output is correct
32 Correct 45 ms 2008 KB Output is correct
33 Correct 44 ms 1912 KB Output is correct
34 Correct 43 ms 1912 KB Output is correct
35 Correct 46 ms 1912 KB Output is correct
36 Correct 46 ms 1912 KB Output is correct
37 Correct 167 ms 3576 KB Output is correct
38 Correct 173 ms 3580 KB Output is correct
39 Correct 239 ms 4216 KB Output is correct
40 Correct 301 ms 4856 KB Output is correct
41 Correct 284 ms 4600 KB Output is correct
42 Correct 261 ms 4440 KB Output is correct
43 Correct 258 ms 4472 KB Output is correct
44 Correct 257 ms 4600 KB Output is correct
45 Correct 267 ms 4600 KB Output is correct
46 Correct 289 ms 4472 KB Output is correct
47 Correct 259 ms 4600 KB Output is correct
48 Correct 263 ms 4600 KB Output is correct
49 Correct 243 ms 4344 KB Output is correct
50 Correct 263 ms 4472 KB Output is correct
51 Correct 245 ms 4216 KB Output is correct
52 Correct 310 ms 4984 KB Output is correct
53 Correct 377 ms 5496 KB Output is correct
54 Correct 502 ms 6136 KB Output is correct
55 Correct 520 ms 6576 KB Output is correct
56 Correct 387 ms 5624 KB Output is correct
57 Correct 526 ms 6520 KB Output is correct
58 Correct 499 ms 6136 KB Output is correct
59 Correct 512 ms 6392 KB Output is correct
60 Correct 482 ms 5752 KB Output is correct
61 Correct 518 ms 6356 KB Output is correct
62 Correct 435 ms 5920 KB Output is correct
63 Correct 448 ms 5932 KB Output is correct
64 Correct 433 ms 6008 KB Output is correct
65 Correct 404 ms 5368 KB Output is correct
66 Correct 384 ms 5240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 6 ms 640 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
11 Correct 9 ms 896 KB Output is correct
12 Correct 9 ms 896 KB Output is correct
13 Correct 8 ms 768 KB Output is correct
14 Correct 9 ms 896 KB Output is correct
15 Correct 8 ms 768 KB Output is correct
16 Correct 9 ms 896 KB Output is correct
17 Correct 7 ms 640 KB Output is correct
18 Correct 8 ms 768 KB Output is correct
19 Correct 8 ms 768 KB Output is correct
20 Correct 9 ms 896 KB Output is correct
21 Correct 22 ms 1408 KB Output is correct
22 Correct 28 ms 1528 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 41 ms 1912 KB Output is correct
25 Correct 45 ms 1912 KB Output is correct
26 Correct 45 ms 1916 KB Output is correct
27 Correct 47 ms 1912 KB Output is correct
28 Correct 46 ms 1912 KB Output is correct
29 Correct 44 ms 1912 KB Output is correct
30 Correct 45 ms 1912 KB Output is correct
31 Correct 46 ms 2040 KB Output is correct
32 Correct 45 ms 2008 KB Output is correct
33 Correct 44 ms 1912 KB Output is correct
34 Correct 43 ms 1912 KB Output is correct
35 Correct 46 ms 1912 KB Output is correct
36 Correct 46 ms 1912 KB Output is correct
37 Correct 167 ms 3576 KB Output is correct
38 Correct 173 ms 3580 KB Output is correct
39 Correct 239 ms 4216 KB Output is correct
40 Correct 301 ms 4856 KB Output is correct
41 Correct 284 ms 4600 KB Output is correct
42 Correct 261 ms 4440 KB Output is correct
43 Correct 258 ms 4472 KB Output is correct
44 Correct 257 ms 4600 KB Output is correct
45 Correct 267 ms 4600 KB Output is correct
46 Correct 289 ms 4472 KB Output is correct
47 Correct 259 ms 4600 KB Output is correct
48 Correct 263 ms 4600 KB Output is correct
49 Correct 243 ms 4344 KB Output is correct
50 Correct 263 ms 4472 KB Output is correct
51 Correct 245 ms 4216 KB Output is correct
52 Correct 310 ms 4984 KB Output is correct
53 Correct 377 ms 5496 KB Output is correct
54 Correct 502 ms 6136 KB Output is correct
55 Correct 520 ms 6576 KB Output is correct
56 Correct 387 ms 5624 KB Output is correct
57 Correct 526 ms 6520 KB Output is correct
58 Correct 499 ms 6136 KB Output is correct
59 Correct 512 ms 6392 KB Output is correct
60 Correct 482 ms 5752 KB Output is correct
61 Correct 518 ms 6356 KB Output is correct
62 Correct 435 ms 5920 KB Output is correct
63 Correct 448 ms 5932 KB Output is correct
64 Correct 433 ms 6008 KB Output is correct
65 Correct 404 ms 5368 KB Output is correct
66 Correct 384 ms 5240 KB Output is correct
67 Correct 687 ms 7160 KB Output is correct
68 Correct 973 ms 8140 KB Output is correct
69 Incorrect 983 ms 8388 KB Output isn't correct
70 Halted 0 ms 0 KB -