Submission #700078

# Submission time Handle Problem Language Result Execution time Memory
700078 2023-02-18T15:46:20 Z fdnfksd Bootfall (IZhO17_bootfall) C++14
100 / 100
620 ms 3444 KB
#include<bits/stdc++.h>
#define TASKNAME "bieudo"
#define pb push_back
#define pli pair<int,int>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=int;
const ll maxN=600;
const ll mod=1e9+19972207;
ll dp[505*505];
ll cnt[505*505]={0};
ll n,a[maxN];
void solve()
{
    cin >> n;
    ll m=0;
    for(int i=1;i<=n;i++) cin >> a[i],m+=a[i];
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=m;j>=a[i];j--)
        {
            dp[j]+=dp[j-a[i]];
            if(dp[j]>=mod) dp[j]-=mod;
            //dp2[j]+=dp2[j-a[i]];
            //if(dp2[j]>=mod2) dp2[j]-=mod2;
        }
    }
    if(m%2!=0)
    {
        cout << 0;
        return;
    }
    ll x=m/2;
    if(dp[x]==0)
    {
        cout << 0;
        return;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=a[i];j<=m;j++)
        {
            dp[j]-=dp[j-a[i]];
            if(dp[j]<0) dp[j]+=mod;
        }
        for(int j=0;j<=(m-a[i])/2;j++)
        {
            if(dp[j]>0)
            {
                cnt[m-j-a[i]-j]++;
            }
        }
        for(int j=m;j>=a[i];j--)
        {
            dp[j]+=dp[j-a[i]];
            if(dp[j]>=mod) dp[j]-=mod;
        }
    }
    vector<ll> ans;
    for(int i=1;i<=m;i++)
    {
        if(cnt[i]==n)
        {
            ans.pb(i);
        }
    }
    cout <<ans.size()<<'\n';
    for(auto zz:ans) cout << zz <<' ';
}
int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 5 ms 452 KB Output is correct
27 Correct 4 ms 324 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 4 ms 328 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 5 ms 392 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 4 ms 408 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 5 ms 452 KB Output is correct
27 Correct 4 ms 324 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 4 ms 328 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 5 ms 392 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 4 ms 408 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 20 ms 596 KB Output is correct
38 Correct 21 ms 604 KB Output is correct
39 Correct 49 ms 700 KB Output is correct
40 Correct 29 ms 708 KB Output is correct
41 Correct 62 ms 880 KB Output is correct
42 Correct 26 ms 688 KB Output is correct
43 Correct 64 ms 1008 KB Output is correct
44 Correct 53 ms 1136 KB Output is correct
45 Correct 52 ms 1144 KB Output is correct
46 Correct 41 ms 468 KB Output is correct
47 Correct 36 ms 692 KB Output is correct
48 Correct 53 ms 1052 KB Output is correct
49 Correct 73 ms 788 KB Output is correct
50 Correct 29 ms 700 KB Output is correct
51 Correct 13 ms 448 KB Output is correct
52 Correct 68 ms 1248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 5 ms 452 KB Output is correct
27 Correct 4 ms 324 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 4 ms 328 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 5 ms 392 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 4 ms 408 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 20 ms 596 KB Output is correct
38 Correct 21 ms 604 KB Output is correct
39 Correct 49 ms 700 KB Output is correct
40 Correct 29 ms 708 KB Output is correct
41 Correct 62 ms 880 KB Output is correct
42 Correct 26 ms 688 KB Output is correct
43 Correct 64 ms 1008 KB Output is correct
44 Correct 53 ms 1136 KB Output is correct
45 Correct 52 ms 1144 KB Output is correct
46 Correct 41 ms 468 KB Output is correct
47 Correct 36 ms 692 KB Output is correct
48 Correct 53 ms 1052 KB Output is correct
49 Correct 73 ms 788 KB Output is correct
50 Correct 29 ms 700 KB Output is correct
51 Correct 13 ms 448 KB Output is correct
52 Correct 68 ms 1248 KB Output is correct
53 Correct 44 ms 952 KB Output is correct
54 Correct 72 ms 1128 KB Output is correct
55 Correct 128 ms 1696 KB Output is correct
56 Correct 61 ms 1128 KB Output is correct
57 Correct 150 ms 1868 KB Output is correct
58 Correct 73 ms 1200 KB Output is correct
59 Correct 96 ms 1296 KB Output is correct
60 Correct 23 ms 468 KB Output is correct
61 Correct 114 ms 1496 KB Output is correct
62 Correct 105 ms 1576 KB Output is correct
63 Correct 111 ms 1636 KB Output is correct
64 Correct 105 ms 1620 KB Output is correct
65 Correct 55 ms 596 KB Output is correct
66 Correct 58 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 5 ms 452 KB Output is correct
27 Correct 4 ms 324 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 4 ms 328 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 5 ms 392 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 4 ms 408 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 20 ms 596 KB Output is correct
38 Correct 21 ms 604 KB Output is correct
39 Correct 49 ms 700 KB Output is correct
40 Correct 29 ms 708 KB Output is correct
41 Correct 62 ms 880 KB Output is correct
42 Correct 26 ms 688 KB Output is correct
43 Correct 64 ms 1008 KB Output is correct
44 Correct 53 ms 1136 KB Output is correct
45 Correct 52 ms 1144 KB Output is correct
46 Correct 41 ms 468 KB Output is correct
47 Correct 36 ms 692 KB Output is correct
48 Correct 53 ms 1052 KB Output is correct
49 Correct 73 ms 788 KB Output is correct
50 Correct 29 ms 700 KB Output is correct
51 Correct 13 ms 448 KB Output is correct
52 Correct 68 ms 1248 KB Output is correct
53 Correct 44 ms 952 KB Output is correct
54 Correct 72 ms 1128 KB Output is correct
55 Correct 128 ms 1696 KB Output is correct
56 Correct 61 ms 1128 KB Output is correct
57 Correct 150 ms 1868 KB Output is correct
58 Correct 73 ms 1200 KB Output is correct
59 Correct 96 ms 1296 KB Output is correct
60 Correct 23 ms 468 KB Output is correct
61 Correct 114 ms 1496 KB Output is correct
62 Correct 105 ms 1576 KB Output is correct
63 Correct 111 ms 1636 KB Output is correct
64 Correct 105 ms 1620 KB Output is correct
65 Correct 55 ms 596 KB Output is correct
66 Correct 58 ms 724 KB Output is correct
67 Correct 111 ms 1452 KB Output is correct
68 Correct 67 ms 788 KB Output is correct
69 Correct 349 ms 3184 KB Output is correct
70 Correct 242 ms 2088 KB Output is correct
71 Correct 198 ms 2056 KB Output is correct
72 Correct 237 ms 1292 KB Output is correct
73 Correct 203 ms 1188 KB Output is correct
74 Correct 566 ms 3208 KB Output is correct
75 Correct 415 ms 2696 KB Output is correct
76 Correct 432 ms 3380 KB Output is correct
77 Correct 620 ms 3444 KB Output is correct