Submission #975348

# Submission time Handle Problem Language Result Execution time Memory
975348 2024-05-05T01:35:47 Z 12345678 Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 13252 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=505, kx=250005;

int n, a[nx], sm;
bitset<kx> dp[nx];
vector<int> res;

bool valid(int x)
{
    for (int i=1; i<=n; i++) if (((sm-a[i]+x)%2)||(!dp[i][(sm-a[i]+x)/2])) return 0;
    return 1;
}
int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i], sm+=a[i];
    for (int i=0; i<=n; i++) dp[i][0]=1;
    for (int i=1; i<=n; i++) dp[0]=dp[0]|(dp[0]<<a[i]);
    for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) if (j!=i) dp[i]=dp[i]|(dp[i]<<a[j]);
    if ((sm%2)||!dp[0][sm/2]) return cout<<0, 0;
    for (int i=1; i<kx; i++) if (valid(i)) res.push_back(i);
    cout<<res.size()<<'\n';
    for (auto x:res) cout<<x<<' ';
}

/*
4
1 3 1 5
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 2 ms 2648 KB Output is correct
8 Correct 3 ms 2760 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 2 ms 2648 KB Output is correct
8 Correct 3 ms 2760 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 9 ms 2648 KB Output is correct
11 Correct 10 ms 2652 KB Output is correct
12 Correct 9 ms 2648 KB Output is correct
13 Correct 7 ms 2652 KB Output is correct
14 Correct 8 ms 2652 KB Output is correct
15 Correct 10 ms 2652 KB Output is correct
16 Correct 9 ms 2756 KB Output is correct
17 Correct 5 ms 2648 KB Output is correct
18 Correct 7 ms 2648 KB Output is correct
19 Correct 7 ms 2652 KB Output is correct
20 Correct 9 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 2 ms 2648 KB Output is correct
8 Correct 3 ms 2760 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 9 ms 2648 KB Output is correct
11 Correct 10 ms 2652 KB Output is correct
12 Correct 9 ms 2648 KB Output is correct
13 Correct 7 ms 2652 KB Output is correct
14 Correct 8 ms 2652 KB Output is correct
15 Correct 10 ms 2652 KB Output is correct
16 Correct 9 ms 2756 KB Output is correct
17 Correct 5 ms 2648 KB Output is correct
18 Correct 7 ms 2648 KB Output is correct
19 Correct 7 ms 2652 KB Output is correct
20 Correct 9 ms 2652 KB Output is correct
21 Correct 36 ms 2744 KB Output is correct
22 Correct 48 ms 4780 KB Output is correct
23 Correct 28 ms 2652 KB Output is correct
24 Correct 77 ms 4948 KB Output is correct
25 Correct 76 ms 4808 KB Output is correct
26 Correct 99 ms 4796 KB Output is correct
27 Correct 85 ms 4800 KB Output is correct
28 Correct 85 ms 4800 KB Output is correct
29 Correct 85 ms 4700 KB Output is correct
30 Correct 106 ms 4792 KB Output is correct
31 Correct 85 ms 4696 KB Output is correct
32 Correct 85 ms 4800 KB Output is correct
33 Correct 85 ms 4944 KB Output is correct
34 Correct 85 ms 4700 KB Output is correct
35 Correct 85 ms 4788 KB Output is correct
36 Correct 86 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 2 ms 2648 KB Output is correct
8 Correct 3 ms 2760 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 9 ms 2648 KB Output is correct
11 Correct 10 ms 2652 KB Output is correct
12 Correct 9 ms 2648 KB Output is correct
13 Correct 7 ms 2652 KB Output is correct
14 Correct 8 ms 2652 KB Output is correct
15 Correct 10 ms 2652 KB Output is correct
16 Correct 9 ms 2756 KB Output is correct
17 Correct 5 ms 2648 KB Output is correct
18 Correct 7 ms 2648 KB Output is correct
19 Correct 7 ms 2652 KB Output is correct
20 Correct 9 ms 2652 KB Output is correct
21 Correct 36 ms 2744 KB Output is correct
22 Correct 48 ms 4780 KB Output is correct
23 Correct 28 ms 2652 KB Output is correct
24 Correct 77 ms 4948 KB Output is correct
25 Correct 76 ms 4808 KB Output is correct
26 Correct 99 ms 4796 KB Output is correct
27 Correct 85 ms 4800 KB Output is correct
28 Correct 85 ms 4800 KB Output is correct
29 Correct 85 ms 4700 KB Output is correct
30 Correct 106 ms 4792 KB Output is correct
31 Correct 85 ms 4696 KB Output is correct
32 Correct 85 ms 4800 KB Output is correct
33 Correct 85 ms 4944 KB Output is correct
34 Correct 85 ms 4700 KB Output is correct
35 Correct 85 ms 4788 KB Output is correct
36 Correct 86 ms 4696 KB Output is correct
37 Correct 379 ms 6832 KB Output is correct
38 Correct 379 ms 6836 KB Output is correct
39 Correct 519 ms 8896 KB Output is correct
40 Correct 628 ms 8904 KB Output is correct
41 Correct 622 ms 8884 KB Output is correct
42 Correct 558 ms 8896 KB Output is correct
43 Correct 515 ms 9296 KB Output is correct
44 Correct 574 ms 9300 KB Output is correct
45 Correct 542 ms 9040 KB Output is correct
46 Correct 617 ms 8888 KB Output is correct
47 Correct 546 ms 8960 KB Output is correct
48 Correct 552 ms 9144 KB Output is correct
49 Correct 535 ms 8880 KB Output is correct
50 Correct 535 ms 8892 KB Output is correct
51 Correct 539 ms 8792 KB Output is correct
52 Correct 623 ms 9300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 2 ms 2648 KB Output is correct
8 Correct 3 ms 2760 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 9 ms 2648 KB Output is correct
11 Correct 10 ms 2652 KB Output is correct
12 Correct 9 ms 2648 KB Output is correct
13 Correct 7 ms 2652 KB Output is correct
14 Correct 8 ms 2652 KB Output is correct
15 Correct 10 ms 2652 KB Output is correct
16 Correct 9 ms 2756 KB Output is correct
17 Correct 5 ms 2648 KB Output is correct
18 Correct 7 ms 2648 KB Output is correct
19 Correct 7 ms 2652 KB Output is correct
20 Correct 9 ms 2652 KB Output is correct
21 Correct 36 ms 2744 KB Output is correct
22 Correct 48 ms 4780 KB Output is correct
23 Correct 28 ms 2652 KB Output is correct
24 Correct 77 ms 4948 KB Output is correct
25 Correct 76 ms 4808 KB Output is correct
26 Correct 99 ms 4796 KB Output is correct
27 Correct 85 ms 4800 KB Output is correct
28 Correct 85 ms 4800 KB Output is correct
29 Correct 85 ms 4700 KB Output is correct
30 Correct 106 ms 4792 KB Output is correct
31 Correct 85 ms 4696 KB Output is correct
32 Correct 85 ms 4800 KB Output is correct
33 Correct 85 ms 4944 KB Output is correct
34 Correct 85 ms 4700 KB Output is correct
35 Correct 85 ms 4788 KB Output is correct
36 Correct 86 ms 4696 KB Output is correct
37 Correct 379 ms 6832 KB Output is correct
38 Correct 379 ms 6836 KB Output is correct
39 Correct 519 ms 8896 KB Output is correct
40 Correct 628 ms 8904 KB Output is correct
41 Correct 622 ms 8884 KB Output is correct
42 Correct 558 ms 8896 KB Output is correct
43 Correct 515 ms 9296 KB Output is correct
44 Correct 574 ms 9300 KB Output is correct
45 Correct 542 ms 9040 KB Output is correct
46 Correct 617 ms 8888 KB Output is correct
47 Correct 546 ms 8960 KB Output is correct
48 Correct 552 ms 9144 KB Output is correct
49 Correct 535 ms 8880 KB Output is correct
50 Correct 535 ms 8892 KB Output is correct
51 Correct 539 ms 8792 KB Output is correct
52 Correct 623 ms 9300 KB Output is correct
53 Correct 784 ms 11192 KB Output is correct
54 Execution timed out 1051 ms 13252 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 2 ms 2648 KB Output is correct
8 Correct 3 ms 2760 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 9 ms 2648 KB Output is correct
11 Correct 10 ms 2652 KB Output is correct
12 Correct 9 ms 2648 KB Output is correct
13 Correct 7 ms 2652 KB Output is correct
14 Correct 8 ms 2652 KB Output is correct
15 Correct 10 ms 2652 KB Output is correct
16 Correct 9 ms 2756 KB Output is correct
17 Correct 5 ms 2648 KB Output is correct
18 Correct 7 ms 2648 KB Output is correct
19 Correct 7 ms 2652 KB Output is correct
20 Correct 9 ms 2652 KB Output is correct
21 Correct 36 ms 2744 KB Output is correct
22 Correct 48 ms 4780 KB Output is correct
23 Correct 28 ms 2652 KB Output is correct
24 Correct 77 ms 4948 KB Output is correct
25 Correct 76 ms 4808 KB Output is correct
26 Correct 99 ms 4796 KB Output is correct
27 Correct 85 ms 4800 KB Output is correct
28 Correct 85 ms 4800 KB Output is correct
29 Correct 85 ms 4700 KB Output is correct
30 Correct 106 ms 4792 KB Output is correct
31 Correct 85 ms 4696 KB Output is correct
32 Correct 85 ms 4800 KB Output is correct
33 Correct 85 ms 4944 KB Output is correct
34 Correct 85 ms 4700 KB Output is correct
35 Correct 85 ms 4788 KB Output is correct
36 Correct 86 ms 4696 KB Output is correct
37 Correct 379 ms 6832 KB Output is correct
38 Correct 379 ms 6836 KB Output is correct
39 Correct 519 ms 8896 KB Output is correct
40 Correct 628 ms 8904 KB Output is correct
41 Correct 622 ms 8884 KB Output is correct
42 Correct 558 ms 8896 KB Output is correct
43 Correct 515 ms 9296 KB Output is correct
44 Correct 574 ms 9300 KB Output is correct
45 Correct 542 ms 9040 KB Output is correct
46 Correct 617 ms 8888 KB Output is correct
47 Correct 546 ms 8960 KB Output is correct
48 Correct 552 ms 9144 KB Output is correct
49 Correct 535 ms 8880 KB Output is correct
50 Correct 535 ms 8892 KB Output is correct
51 Correct 539 ms 8792 KB Output is correct
52 Correct 623 ms 9300 KB Output is correct
53 Correct 784 ms 11192 KB Output is correct
54 Execution timed out 1051 ms 13252 KB Time limit exceeded
55 Halted 0 ms 0 KB -