Submission #566539

# Submission time Handle Problem Language Result Execution time Memory
566539 2022-05-22T11:37:26 Z milisav Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 3128 KB
    #include"bits/stdc++.h"
    using namespace std;
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    template<class x>
    using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //bool plc[600000];
    const int mod=1e9+7;
    int occ[2500000];
    int good[2500006],a[5005],maxn;
    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int n,sum=0;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        maxn=sum;
        sort(a,a+n);
        //reverse(a,a+n);
        //plc[0]=true;
        vector <int> h;
        occ[0]=1;
        //yes.push_back(0);
        for(int i=0;i<n;i++)
        {
            for(int j=maxn;j>=a[i];j--)
            {
                occ[j]+=occ[j-a[i]];
                while(occ[j]>mod)
                    occ[j]-=mod;
            }
        }
        
        //cout<<"HI"<<endl;
        if(occ[sum/2]!=0&&sum%2==0)
        {
            for(int k=0;k<n;k++)
            {
                sum-=a[k];
                for(int i=a[k];i<=maxn;i++)
                {
                    if(occ[i-a[k]]!=0){
                    occ[i]-=occ[i-a[k]];
                    if(occ[i]<0)
                        occ[i]+=mod;
                    
                    }
                }
                /*for(int i=0;i<=15;i++)
                {
                    cout<<occ[i]<<" ";
                }
                cout<<"\n";*/
                //cout<<"HELLO"<<endl;
                for(int i=0;i<=sum;i++)
                {
                    int oth=i-(sum-i);
                    if(oth<=0||oth>=maxn)
                        continue;
                    if(occ[i]!=0){
                        good[oth]++;
                        //cout<<oth<<" ";
                        //cout<<oth<<" ";
                    }
                }
                for(int i=maxn;i>=a[k];i--)
                {
                    if(occ[i-a[k]]!=0){
                    occ[i]+=occ[i-a[k]];
                    while(occ[i]>mod)
                        occ[i]-=mod;
                    }
                }
                //cout<<endl;
                sum+=a[k];
            }
            
        }
        for(int i=1;i<=maxn;i++)
            {
     
                    if(good[i]==n){
                        //cout<<"???"<<endl;
                        h.push_back(i);
            }
        }
        cout<<h.size()<<"\n";
        for(auto i : h)
            cout<<i<<" ";
    }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 372 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 16 ms 404 KB Output is correct
26 Correct 18 ms 408 KB Output is correct
27 Correct 7 ms 412 KB Output is correct
28 Correct 6 ms 340 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 12 ms 340 KB Output is correct
35 Correct 15 ms 380 KB Output is correct
36 Correct 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 372 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 16 ms 404 KB Output is correct
26 Correct 18 ms 408 KB Output is correct
27 Correct 7 ms 412 KB Output is correct
28 Correct 6 ms 340 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 12 ms 340 KB Output is correct
35 Correct 15 ms 380 KB Output is correct
36 Correct 5 ms 380 KB Output is correct
37 Correct 57 ms 600 KB Output is correct
38 Correct 36 ms 536 KB Output is correct
39 Correct 77 ms 684 KB Output is correct
40 Correct 87 ms 700 KB Output is correct
41 Correct 76 ms 872 KB Output is correct
42 Correct 70 ms 692 KB Output is correct
43 Correct 133 ms 1132 KB Output is correct
44 Correct 135 ms 1148 KB Output is correct
45 Correct 150 ms 1152 KB Output is correct
46 Correct 76 ms 568 KB Output is correct
47 Correct 89 ms 704 KB Output is correct
48 Correct 133 ms 1060 KB Output is correct
49 Correct 103 ms 804 KB Output is correct
50 Correct 82 ms 708 KB Output is correct
51 Correct 20 ms 452 KB Output is correct
52 Correct 190 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 372 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 16 ms 404 KB Output is correct
26 Correct 18 ms 408 KB Output is correct
27 Correct 7 ms 412 KB Output is correct
28 Correct 6 ms 340 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 12 ms 340 KB Output is correct
35 Correct 15 ms 380 KB Output is correct
36 Correct 5 ms 380 KB Output is correct
37 Correct 57 ms 600 KB Output is correct
38 Correct 36 ms 536 KB Output is correct
39 Correct 77 ms 684 KB Output is correct
40 Correct 87 ms 700 KB Output is correct
41 Correct 76 ms 872 KB Output is correct
42 Correct 70 ms 692 KB Output is correct
43 Correct 133 ms 1132 KB Output is correct
44 Correct 135 ms 1148 KB Output is correct
45 Correct 150 ms 1152 KB Output is correct
46 Correct 76 ms 568 KB Output is correct
47 Correct 89 ms 704 KB Output is correct
48 Correct 133 ms 1060 KB Output is correct
49 Correct 103 ms 804 KB Output is correct
50 Correct 82 ms 708 KB Output is correct
51 Correct 20 ms 452 KB Output is correct
52 Correct 190 ms 1252 KB Output is correct
53 Correct 141 ms 1008 KB Output is correct
54 Correct 194 ms 1136 KB Output is correct
55 Correct 363 ms 1704 KB Output is correct
56 Correct 169 ms 1052 KB Output is correct
57 Correct 421 ms 1884 KB Output is correct
58 Correct 205 ms 1228 KB Output is correct
59 Correct 265 ms 1304 KB Output is correct
60 Correct 53 ms 468 KB Output is correct
61 Correct 318 ms 1508 KB Output is correct
62 Correct 330 ms 1588 KB Output is correct
63 Correct 320 ms 1760 KB Output is correct
64 Correct 321 ms 1616 KB Output is correct
65 Correct 78 ms 704 KB Output is correct
66 Correct 90 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 372 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 16 ms 404 KB Output is correct
26 Correct 18 ms 408 KB Output is correct
27 Correct 7 ms 412 KB Output is correct
28 Correct 6 ms 340 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 12 ms 340 KB Output is correct
35 Correct 15 ms 380 KB Output is correct
36 Correct 5 ms 380 KB Output is correct
37 Correct 57 ms 600 KB Output is correct
38 Correct 36 ms 536 KB Output is correct
39 Correct 77 ms 684 KB Output is correct
40 Correct 87 ms 700 KB Output is correct
41 Correct 76 ms 872 KB Output is correct
42 Correct 70 ms 692 KB Output is correct
43 Correct 133 ms 1132 KB Output is correct
44 Correct 135 ms 1148 KB Output is correct
45 Correct 150 ms 1152 KB Output is correct
46 Correct 76 ms 568 KB Output is correct
47 Correct 89 ms 704 KB Output is correct
48 Correct 133 ms 1060 KB Output is correct
49 Correct 103 ms 804 KB Output is correct
50 Correct 82 ms 708 KB Output is correct
51 Correct 20 ms 452 KB Output is correct
52 Correct 190 ms 1252 KB Output is correct
53 Correct 141 ms 1008 KB Output is correct
54 Correct 194 ms 1136 KB Output is correct
55 Correct 363 ms 1704 KB Output is correct
56 Correct 169 ms 1052 KB Output is correct
57 Correct 421 ms 1884 KB Output is correct
58 Correct 205 ms 1228 KB Output is correct
59 Correct 265 ms 1304 KB Output is correct
60 Correct 53 ms 468 KB Output is correct
61 Correct 318 ms 1508 KB Output is correct
62 Correct 330 ms 1588 KB Output is correct
63 Correct 320 ms 1760 KB Output is correct
64 Correct 321 ms 1616 KB Output is correct
65 Correct 78 ms 704 KB Output is correct
66 Correct 90 ms 744 KB Output is correct
67 Correct 310 ms 1480 KB Output is correct
68 Correct 123 ms 796 KB Output is correct
69 Execution timed out 1082 ms 3128 KB Time limit exceeded
70 Halted 0 ms 0 KB -