Submission #342723

# Submission time Handle Problem Language Result Execution time Memory
342723 2021-01-02T16:50:21 Z ivan_tudor Bootfall (IZhO17_bootfall) C++14
100 / 100
616 ms 2284 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 505;
int dp[N*N];
const int EMPTY = INT_MAX;
int v[N];
bool good[N * N];
int main()
{
  //freopen(".in","r",stdin);
  ios::sync_with_stdio(false);
  cin.tie(0),cout.tie(0);
  int n;
  cin>>n;
  int sum = 0;
  for(int i=1;i<=n;i++){
    cin>>v[i];
    sum += v[i];
  }
  for(int i=0; i< N*N; i++)
    dp[i] = EMPTY, good[i] = true;
  dp[0] = 0;
  for(int i = 1; i<=n;i ++){
    for(int val = N*N - 1 - v[i]; val >=0; val--){
      if(dp[val] != EMPTY){
        dp[val + v[i]] = min(dp[val + v[i]], i);
      }
    }
  }
  if(sum%2 == 1 || (dp[sum/2] == EMPTY)){
    cout<<"0\n";
    return 0;
  }
  for(int i = n; i >=1; i--){
    for(int val = N*N -1; val >=0; val--){
      if(dp[val] == i)
        dp[val] = EMPTY;
    }
    if(i + 1 <= n){
      for(int val = N*N -1 - v[i + 1]; val>=0; val--){
        if(dp[val] != EMPTY){
          dp[val + v[i + 1]] = min(dp[val + v[i + 1]], dp[val]);
        }
      }
    }
    for(int news = 1; news< N*N; news ++){
      if(good[news] == false)
        continue;
      int newsum = sum - v[i] + news;
      if(newsum %2 == 1 || (dp[newsum / 2] == EMPTY))
        good[news] = false;
    }
  }
  int goodval = 0;
  for(int i=1; i<N*N; i++){
    if(good[i] == true)
      goodval++;
  }
  cout<<goodval<<"\n";
  for(int i=1; i< N*N; i++){
    if(good[i] == true){
      cout<<i<<" ";
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1644 KB Output is correct
2 Correct 8 ms 1644 KB Output is correct
3 Correct 3 ms 1644 KB Output is correct
4 Correct 6 ms 1644 KB Output is correct
5 Correct 14 ms 1644 KB Output is correct
6 Correct 10 ms 1644 KB Output is correct
7 Correct 8 ms 1644 KB Output is correct
8 Correct 14 ms 1644 KB Output is correct
9 Correct 12 ms 1644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1644 KB Output is correct
2 Correct 8 ms 1644 KB Output is correct
3 Correct 3 ms 1644 KB Output is correct
4 Correct 6 ms 1644 KB Output is correct
5 Correct 14 ms 1644 KB Output is correct
6 Correct 10 ms 1644 KB Output is correct
7 Correct 8 ms 1644 KB Output is correct
8 Correct 14 ms 1644 KB Output is correct
9 Correct 12 ms 1644 KB Output is correct
10 Correct 31 ms 1644 KB Output is correct
11 Correct 34 ms 1644 KB Output is correct
12 Correct 31 ms 1644 KB Output is correct
13 Correct 27 ms 1644 KB Output is correct
14 Correct 32 ms 1644 KB Output is correct
15 Correct 33 ms 1644 KB Output is correct
16 Correct 31 ms 1644 KB Output is correct
17 Correct 25 ms 1644 KB Output is correct
18 Correct 25 ms 1644 KB Output is correct
19 Correct 28 ms 1644 KB Output is correct
20 Correct 32 ms 1644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1644 KB Output is correct
2 Correct 8 ms 1644 KB Output is correct
3 Correct 3 ms 1644 KB Output is correct
4 Correct 6 ms 1644 KB Output is correct
5 Correct 14 ms 1644 KB Output is correct
6 Correct 10 ms 1644 KB Output is correct
7 Correct 8 ms 1644 KB Output is correct
8 Correct 14 ms 1644 KB Output is correct
9 Correct 12 ms 1644 KB Output is correct
10 Correct 31 ms 1644 KB Output is correct
11 Correct 34 ms 1644 KB Output is correct
12 Correct 31 ms 1644 KB Output is correct
13 Correct 27 ms 1644 KB Output is correct
14 Correct 32 ms 1644 KB Output is correct
15 Correct 33 ms 1644 KB Output is correct
16 Correct 31 ms 1644 KB Output is correct
17 Correct 25 ms 1644 KB Output is correct
18 Correct 25 ms 1644 KB Output is correct
19 Correct 28 ms 1644 KB Output is correct
20 Correct 32 ms 1644 KB Output is correct
21 Correct 65 ms 1644 KB Output is correct
22 Correct 77 ms 1644 KB Output is correct
23 Correct 60 ms 1644 KB Output is correct
24 Correct 96 ms 1644 KB Output is correct
25 Correct 97 ms 1644 KB Output is correct
26 Correct 101 ms 1644 KB Output is correct
27 Correct 114 ms 1644 KB Output is correct
28 Correct 102 ms 1644 KB Output is correct
29 Correct 102 ms 1644 KB Output is correct
30 Correct 100 ms 1644 KB Output is correct
31 Correct 100 ms 1644 KB Output is correct
32 Correct 102 ms 1644 KB Output is correct
33 Correct 102 ms 1644 KB Output is correct
34 Correct 101 ms 1644 KB Output is correct
35 Correct 100 ms 1644 KB Output is correct
36 Correct 100 ms 1644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1644 KB Output is correct
2 Correct 8 ms 1644 KB Output is correct
3 Correct 3 ms 1644 KB Output is correct
4 Correct 6 ms 1644 KB Output is correct
5 Correct 14 ms 1644 KB Output is correct
6 Correct 10 ms 1644 KB Output is correct
7 Correct 8 ms 1644 KB Output is correct
8 Correct 14 ms 1644 KB Output is correct
9 Correct 12 ms 1644 KB Output is correct
10 Correct 31 ms 1644 KB Output is correct
11 Correct 34 ms 1644 KB Output is correct
12 Correct 31 ms 1644 KB Output is correct
13 Correct 27 ms 1644 KB Output is correct
14 Correct 32 ms 1644 KB Output is correct
15 Correct 33 ms 1644 KB Output is correct
16 Correct 31 ms 1644 KB Output is correct
17 Correct 25 ms 1644 KB Output is correct
18 Correct 25 ms 1644 KB Output is correct
19 Correct 28 ms 1644 KB Output is correct
20 Correct 32 ms 1644 KB Output is correct
21 Correct 65 ms 1644 KB Output is correct
22 Correct 77 ms 1644 KB Output is correct
23 Correct 60 ms 1644 KB Output is correct
24 Correct 96 ms 1644 KB Output is correct
25 Correct 97 ms 1644 KB Output is correct
26 Correct 101 ms 1644 KB Output is correct
27 Correct 114 ms 1644 KB Output is correct
28 Correct 102 ms 1644 KB Output is correct
29 Correct 102 ms 1644 KB Output is correct
30 Correct 100 ms 1644 KB Output is correct
31 Correct 100 ms 1644 KB Output is correct
32 Correct 102 ms 1644 KB Output is correct
33 Correct 102 ms 1644 KB Output is correct
34 Correct 101 ms 1644 KB Output is correct
35 Correct 100 ms 1644 KB Output is correct
36 Correct 100 ms 1644 KB Output is correct
37 Correct 203 ms 1644 KB Output is correct
38 Correct 207 ms 1664 KB Output is correct
39 Correct 244 ms 1644 KB Output is correct
40 Correct 273 ms 1644 KB Output is correct
41 Correct 270 ms 1644 KB Output is correct
42 Correct 255 ms 1644 KB Output is correct
43 Correct 259 ms 1900 KB Output is correct
44 Correct 263 ms 1772 KB Output is correct
45 Correct 265 ms 1772 KB Output is correct
46 Correct 268 ms 1644 KB Output is correct
47 Correct 261 ms 1644 KB Output is correct
48 Correct 266 ms 1644 KB Output is correct
49 Correct 252 ms 1644 KB Output is correct
50 Correct 258 ms 1644 KB Output is correct
51 Correct 91 ms 1644 KB Output is correct
52 Correct 299 ms 1772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1644 KB Output is correct
2 Correct 8 ms 1644 KB Output is correct
3 Correct 3 ms 1644 KB Output is correct
4 Correct 6 ms 1644 KB Output is correct
5 Correct 14 ms 1644 KB Output is correct
6 Correct 10 ms 1644 KB Output is correct
7 Correct 8 ms 1644 KB Output is correct
8 Correct 14 ms 1644 KB Output is correct
9 Correct 12 ms 1644 KB Output is correct
10 Correct 31 ms 1644 KB Output is correct
11 Correct 34 ms 1644 KB Output is correct
12 Correct 31 ms 1644 KB Output is correct
13 Correct 27 ms 1644 KB Output is correct
14 Correct 32 ms 1644 KB Output is correct
15 Correct 33 ms 1644 KB Output is correct
16 Correct 31 ms 1644 KB Output is correct
17 Correct 25 ms 1644 KB Output is correct
18 Correct 25 ms 1644 KB Output is correct
19 Correct 28 ms 1644 KB Output is correct
20 Correct 32 ms 1644 KB Output is correct
21 Correct 65 ms 1644 KB Output is correct
22 Correct 77 ms 1644 KB Output is correct
23 Correct 60 ms 1644 KB Output is correct
24 Correct 96 ms 1644 KB Output is correct
25 Correct 97 ms 1644 KB Output is correct
26 Correct 101 ms 1644 KB Output is correct
27 Correct 114 ms 1644 KB Output is correct
28 Correct 102 ms 1644 KB Output is correct
29 Correct 102 ms 1644 KB Output is correct
30 Correct 100 ms 1644 KB Output is correct
31 Correct 100 ms 1644 KB Output is correct
32 Correct 102 ms 1644 KB Output is correct
33 Correct 102 ms 1644 KB Output is correct
34 Correct 101 ms 1644 KB Output is correct
35 Correct 100 ms 1644 KB Output is correct
36 Correct 100 ms 1644 KB Output is correct
37 Correct 203 ms 1644 KB Output is correct
38 Correct 207 ms 1664 KB Output is correct
39 Correct 244 ms 1644 KB Output is correct
40 Correct 273 ms 1644 KB Output is correct
41 Correct 270 ms 1644 KB Output is correct
42 Correct 255 ms 1644 KB Output is correct
43 Correct 259 ms 1900 KB Output is correct
44 Correct 263 ms 1772 KB Output is correct
45 Correct 265 ms 1772 KB Output is correct
46 Correct 268 ms 1644 KB Output is correct
47 Correct 261 ms 1644 KB Output is correct
48 Correct 266 ms 1644 KB Output is correct
49 Correct 252 ms 1644 KB Output is correct
50 Correct 258 ms 1644 KB Output is correct
51 Correct 91 ms 1644 KB Output is correct
52 Correct 299 ms 1772 KB Output is correct
53 Correct 324 ms 1772 KB Output is correct
54 Correct 376 ms 1772 KB Output is correct
55 Correct 394 ms 1900 KB Output is correct
56 Correct 321 ms 1792 KB Output is correct
57 Correct 389 ms 1900 KB Output is correct
58 Correct 368 ms 1772 KB Output is correct
59 Correct 389 ms 1772 KB Output is correct
60 Correct 126 ms 1720 KB Output is correct
61 Correct 373 ms 1772 KB Output is correct
62 Correct 346 ms 1900 KB Output is correct
63 Correct 349 ms 1900 KB Output is correct
64 Correct 344 ms 1900 KB Output is correct
65 Correct 327 ms 1792 KB Output is correct
66 Correct 309 ms 1644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1644 KB Output is correct
2 Correct 8 ms 1644 KB Output is correct
3 Correct 3 ms 1644 KB Output is correct
4 Correct 6 ms 1644 KB Output is correct
5 Correct 14 ms 1644 KB Output is correct
6 Correct 10 ms 1644 KB Output is correct
7 Correct 8 ms 1644 KB Output is correct
8 Correct 14 ms 1644 KB Output is correct
9 Correct 12 ms 1644 KB Output is correct
10 Correct 31 ms 1644 KB Output is correct
11 Correct 34 ms 1644 KB Output is correct
12 Correct 31 ms 1644 KB Output is correct
13 Correct 27 ms 1644 KB Output is correct
14 Correct 32 ms 1644 KB Output is correct
15 Correct 33 ms 1644 KB Output is correct
16 Correct 31 ms 1644 KB Output is correct
17 Correct 25 ms 1644 KB Output is correct
18 Correct 25 ms 1644 KB Output is correct
19 Correct 28 ms 1644 KB Output is correct
20 Correct 32 ms 1644 KB Output is correct
21 Correct 65 ms 1644 KB Output is correct
22 Correct 77 ms 1644 KB Output is correct
23 Correct 60 ms 1644 KB Output is correct
24 Correct 96 ms 1644 KB Output is correct
25 Correct 97 ms 1644 KB Output is correct
26 Correct 101 ms 1644 KB Output is correct
27 Correct 114 ms 1644 KB Output is correct
28 Correct 102 ms 1644 KB Output is correct
29 Correct 102 ms 1644 KB Output is correct
30 Correct 100 ms 1644 KB Output is correct
31 Correct 100 ms 1644 KB Output is correct
32 Correct 102 ms 1644 KB Output is correct
33 Correct 102 ms 1644 KB Output is correct
34 Correct 101 ms 1644 KB Output is correct
35 Correct 100 ms 1644 KB Output is correct
36 Correct 100 ms 1644 KB Output is correct
37 Correct 203 ms 1644 KB Output is correct
38 Correct 207 ms 1664 KB Output is correct
39 Correct 244 ms 1644 KB Output is correct
40 Correct 273 ms 1644 KB Output is correct
41 Correct 270 ms 1644 KB Output is correct
42 Correct 255 ms 1644 KB Output is correct
43 Correct 259 ms 1900 KB Output is correct
44 Correct 263 ms 1772 KB Output is correct
45 Correct 265 ms 1772 KB Output is correct
46 Correct 268 ms 1644 KB Output is correct
47 Correct 261 ms 1644 KB Output is correct
48 Correct 266 ms 1644 KB Output is correct
49 Correct 252 ms 1644 KB Output is correct
50 Correct 258 ms 1644 KB Output is correct
51 Correct 91 ms 1644 KB Output is correct
52 Correct 299 ms 1772 KB Output is correct
53 Correct 324 ms 1772 KB Output is correct
54 Correct 376 ms 1772 KB Output is correct
55 Correct 394 ms 1900 KB Output is correct
56 Correct 321 ms 1792 KB Output is correct
57 Correct 389 ms 1900 KB Output is correct
58 Correct 368 ms 1772 KB Output is correct
59 Correct 389 ms 1772 KB Output is correct
60 Correct 126 ms 1720 KB Output is correct
61 Correct 373 ms 1772 KB Output is correct
62 Correct 346 ms 1900 KB Output is correct
63 Correct 349 ms 1900 KB Output is correct
64 Correct 344 ms 1900 KB Output is correct
65 Correct 327 ms 1792 KB Output is correct
66 Correct 309 ms 1644 KB Output is correct
67 Correct 436 ms 1772 KB Output is correct
68 Correct 181 ms 1644 KB Output is correct
69 Correct 601 ms 2284 KB Output is correct
70 Correct 577 ms 2028 KB Output is correct
71 Correct 565 ms 2028 KB Output is correct
72 Correct 507 ms 1644 KB Output is correct
73 Correct 507 ms 1644 KB Output is correct
74 Correct 616 ms 2284 KB Output is correct
75 Correct 594 ms 2284 KB Output is correct
76 Correct 608 ms 2284 KB Output is correct
77 Correct 614 ms 2284 KB Output is correct