Submission #878217

# Submission time Handle Problem Language Result Execution time Memory
878217 2023-11-24T07:26:10 Z alexdd Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 1108 KB
#include<bits/stdc++.h>
using namespace std;
int n,tot;
int a[505];
bitset<500005> dp;
int variante[500005],cntv;
int newv[500005],cntnew;
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        tot+=a[i];
    }
    if(tot%2==1)
    {
        cout<<0;
        return 0;
    }
    for(int i=1;i<=tot;i++)
        variante[++cntv]=i;
    for(int i=0;i<=n;i++)
    {
        dp.reset();
        dp[0]=1;
        for(int j=1;j<=n;j++)
        {
            if(i!=j)
                dp |= (dp<<a[j]);
        }
        if(i==0)
        {
            if(dp[tot/2]==0)
            {
                cout<<0;
                return 0;
            }
            continue;
        }
        cntnew=0;
        for(int j=1;j<=cntv;j++)
        {
            int x = variante[j];
            if((tot-a[i]+x)%2==0 && dp[(tot-a[i]+x)/2])
                newv[++cntnew] = x;
            ///tot - a[i] + x
        }
        cntv=cntnew;
        for(int j=1;j<=cntnew;j++)
            variante[j] = newv[j];
    }
    cout<<cntv<<"\n";
    for(int i=1;i<=cntv;i++)
        cout<<variante[i]<<" ";
    return 0;
}
/**
3
2 2 2
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 12 ms 588 KB Output is correct
11 Correct 12 ms 656 KB Output is correct
12 Correct 12 ms 604 KB Output is correct
13 Correct 9 ms 604 KB Output is correct
14 Correct 10 ms 656 KB Output is correct
15 Correct 18 ms 600 KB Output is correct
16 Correct 12 ms 664 KB Output is correct
17 Correct 5 ms 604 KB Output is correct
18 Correct 8 ms 588 KB Output is correct
19 Correct 9 ms 856 KB Output is correct
20 Correct 12 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 12 ms 588 KB Output is correct
11 Correct 12 ms 656 KB Output is correct
12 Correct 12 ms 604 KB Output is correct
13 Correct 9 ms 604 KB Output is correct
14 Correct 10 ms 656 KB Output is correct
15 Correct 18 ms 600 KB Output is correct
16 Correct 12 ms 664 KB Output is correct
17 Correct 5 ms 604 KB Output is correct
18 Correct 8 ms 588 KB Output is correct
19 Correct 9 ms 856 KB Output is correct
20 Correct 12 ms 604 KB Output is correct
21 Correct 53 ms 668 KB Output is correct
22 Correct 70 ms 600 KB Output is correct
23 Correct 33 ms 648 KB Output is correct
24 Correct 113 ms 664 KB Output is correct
25 Correct 115 ms 684 KB Output is correct
26 Correct 147 ms 700 KB Output is correct
27 Correct 130 ms 600 KB Output is correct
28 Correct 126 ms 604 KB Output is correct
29 Correct 133 ms 604 KB Output is correct
30 Correct 137 ms 660 KB Output is correct
31 Correct 130 ms 680 KB Output is correct
32 Correct 134 ms 656 KB Output is correct
33 Correct 127 ms 676 KB Output is correct
34 Correct 126 ms 672 KB Output is correct
35 Correct 125 ms 604 KB Output is correct
36 Correct 129 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 12 ms 588 KB Output is correct
11 Correct 12 ms 656 KB Output is correct
12 Correct 12 ms 604 KB Output is correct
13 Correct 9 ms 604 KB Output is correct
14 Correct 10 ms 656 KB Output is correct
15 Correct 18 ms 600 KB Output is correct
16 Correct 12 ms 664 KB Output is correct
17 Correct 5 ms 604 KB Output is correct
18 Correct 8 ms 588 KB Output is correct
19 Correct 9 ms 856 KB Output is correct
20 Correct 12 ms 604 KB Output is correct
21 Correct 53 ms 668 KB Output is correct
22 Correct 70 ms 600 KB Output is correct
23 Correct 33 ms 648 KB Output is correct
24 Correct 113 ms 664 KB Output is correct
25 Correct 115 ms 684 KB Output is correct
26 Correct 147 ms 700 KB Output is correct
27 Correct 130 ms 600 KB Output is correct
28 Correct 126 ms 604 KB Output is correct
29 Correct 133 ms 604 KB Output is correct
30 Correct 137 ms 660 KB Output is correct
31 Correct 130 ms 680 KB Output is correct
32 Correct 134 ms 656 KB Output is correct
33 Correct 127 ms 676 KB Output is correct
34 Correct 126 ms 672 KB Output is correct
35 Correct 125 ms 604 KB Output is correct
36 Correct 129 ms 604 KB Output is correct
37 Correct 526 ms 756 KB Output is correct
38 Correct 510 ms 752 KB Output is correct
39 Correct 816 ms 856 KB Output is correct
40 Correct 923 ms 824 KB Output is correct
41 Correct 930 ms 920 KB Output is correct
42 Correct 800 ms 808 KB Output is correct
43 Correct 771 ms 1108 KB Output is correct
44 Correct 781 ms 1104 KB Output is correct
45 Correct 806 ms 960 KB Output is correct
46 Correct 938 ms 792 KB Output is correct
47 Correct 800 ms 852 KB Output is correct
48 Correct 802 ms 956 KB Output is correct
49 Correct 803 ms 944 KB Output is correct
50 Correct 814 ms 848 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 968 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 12 ms 588 KB Output is correct
11 Correct 12 ms 656 KB Output is correct
12 Correct 12 ms 604 KB Output is correct
13 Correct 9 ms 604 KB Output is correct
14 Correct 10 ms 656 KB Output is correct
15 Correct 18 ms 600 KB Output is correct
16 Correct 12 ms 664 KB Output is correct
17 Correct 5 ms 604 KB Output is correct
18 Correct 8 ms 588 KB Output is correct
19 Correct 9 ms 856 KB Output is correct
20 Correct 12 ms 604 KB Output is correct
21 Correct 53 ms 668 KB Output is correct
22 Correct 70 ms 600 KB Output is correct
23 Correct 33 ms 648 KB Output is correct
24 Correct 113 ms 664 KB Output is correct
25 Correct 115 ms 684 KB Output is correct
26 Correct 147 ms 700 KB Output is correct
27 Correct 130 ms 600 KB Output is correct
28 Correct 126 ms 604 KB Output is correct
29 Correct 133 ms 604 KB Output is correct
30 Correct 137 ms 660 KB Output is correct
31 Correct 130 ms 680 KB Output is correct
32 Correct 134 ms 656 KB Output is correct
33 Correct 127 ms 676 KB Output is correct
34 Correct 126 ms 672 KB Output is correct
35 Correct 125 ms 604 KB Output is correct
36 Correct 129 ms 604 KB Output is correct
37 Correct 526 ms 756 KB Output is correct
38 Correct 510 ms 752 KB Output is correct
39 Correct 816 ms 856 KB Output is correct
40 Correct 923 ms 824 KB Output is correct
41 Correct 930 ms 920 KB Output is correct
42 Correct 800 ms 808 KB Output is correct
43 Correct 771 ms 1108 KB Output is correct
44 Correct 781 ms 1104 KB Output is correct
45 Correct 806 ms 960 KB Output is correct
46 Correct 938 ms 792 KB Output is correct
47 Correct 800 ms 852 KB Output is correct
48 Correct 802 ms 956 KB Output is correct
49 Correct 803 ms 944 KB Output is correct
50 Correct 814 ms 848 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 968 ms 1108 KB Output is correct
53 Execution timed out 1016 ms 856 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 12 ms 588 KB Output is correct
11 Correct 12 ms 656 KB Output is correct
12 Correct 12 ms 604 KB Output is correct
13 Correct 9 ms 604 KB Output is correct
14 Correct 10 ms 656 KB Output is correct
15 Correct 18 ms 600 KB Output is correct
16 Correct 12 ms 664 KB Output is correct
17 Correct 5 ms 604 KB Output is correct
18 Correct 8 ms 588 KB Output is correct
19 Correct 9 ms 856 KB Output is correct
20 Correct 12 ms 604 KB Output is correct
21 Correct 53 ms 668 KB Output is correct
22 Correct 70 ms 600 KB Output is correct
23 Correct 33 ms 648 KB Output is correct
24 Correct 113 ms 664 KB Output is correct
25 Correct 115 ms 684 KB Output is correct
26 Correct 147 ms 700 KB Output is correct
27 Correct 130 ms 600 KB Output is correct
28 Correct 126 ms 604 KB Output is correct
29 Correct 133 ms 604 KB Output is correct
30 Correct 137 ms 660 KB Output is correct
31 Correct 130 ms 680 KB Output is correct
32 Correct 134 ms 656 KB Output is correct
33 Correct 127 ms 676 KB Output is correct
34 Correct 126 ms 672 KB Output is correct
35 Correct 125 ms 604 KB Output is correct
36 Correct 129 ms 604 KB Output is correct
37 Correct 526 ms 756 KB Output is correct
38 Correct 510 ms 752 KB Output is correct
39 Correct 816 ms 856 KB Output is correct
40 Correct 923 ms 824 KB Output is correct
41 Correct 930 ms 920 KB Output is correct
42 Correct 800 ms 808 KB Output is correct
43 Correct 771 ms 1108 KB Output is correct
44 Correct 781 ms 1104 KB Output is correct
45 Correct 806 ms 960 KB Output is correct
46 Correct 938 ms 792 KB Output is correct
47 Correct 800 ms 852 KB Output is correct
48 Correct 802 ms 956 KB Output is correct
49 Correct 803 ms 944 KB Output is correct
50 Correct 814 ms 848 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 968 ms 1108 KB Output is correct
53 Execution timed out 1016 ms 856 KB Time limit exceeded
54 Halted 0 ms 0 KB -