Submission #499837

# Submission time Handle Problem Language Result Execution time Memory
499837 2021-12-29T18:42:20 Z Ronin13 Bootfall (IZhO17_bootfall) C++14
100 / 100
539 ms 4484 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define inf 1e9+1
#define linf 1e18+1
using namespace std;

int dp[250001];
int d[250001];
int b[250001];
void solve(){
    int n;cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    dp[0]=1;
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=a[i];
    }
    if(sum&1){
        cout<<0;
        return;
    }
    for(int i=1;i<=n;i++){
        for(int x=250000;x>=0;x--){
            if(x>=a[i])dp[x]+=dp[x-a[i]];
        }
    }
    if(!dp[sum/2]){
        cout<<0;
        return;
    }
    vector<int>ans;
    for(int i=1;i<=n;i++){
        for(int j=0;j<a[i];j++)d[j]=dp[j];
        for(int j=a[i];j<=250000;j++)d[j]=dp[j]-d[j-a[i]];
        for(int j=1;j<=250000;j++){
            if(!d[j])continue;
            int x=2*j+a[i]-sum;
            if(x>0){
                b[x]++;
                if(b[x]==n)ans.pb(x);
            }
        }
    }
    cout<<ans.size()<<"\n";
    for(int to:ans)cout<<to<<' ';

}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int test=1;//cin>>test;
    while(test--)solve();
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 1 ms 1208 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 7 ms 2248 KB Output is correct
6 Correct 5 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 8 ms 2252 KB Output is correct
9 Correct 6 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 1 ms 1208 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 7 ms 2248 KB Output is correct
6 Correct 5 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 8 ms 2252 KB Output is correct
9 Correct 6 ms 2252 KB Output is correct
10 Correct 18 ms 2252 KB Output is correct
11 Correct 21 ms 2268 KB Output is correct
12 Correct 19 ms 2280 KB Output is correct
13 Correct 16 ms 2284 KB Output is correct
14 Correct 16 ms 2232 KB Output is correct
15 Correct 18 ms 2244 KB Output is correct
16 Correct 19 ms 2244 KB Output is correct
17 Correct 12 ms 2240 KB Output is correct
18 Correct 15 ms 2156 KB Output is correct
19 Correct 16 ms 2252 KB Output is correct
20 Correct 17 ms 2204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 1 ms 1208 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 7 ms 2248 KB Output is correct
6 Correct 5 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 8 ms 2252 KB Output is correct
9 Correct 6 ms 2252 KB Output is correct
10 Correct 18 ms 2252 KB Output is correct
11 Correct 21 ms 2268 KB Output is correct
12 Correct 19 ms 2280 KB Output is correct
13 Correct 16 ms 2284 KB Output is correct
14 Correct 16 ms 2232 KB Output is correct
15 Correct 18 ms 2244 KB Output is correct
16 Correct 19 ms 2244 KB Output is correct
17 Correct 12 ms 2240 KB Output is correct
18 Correct 15 ms 2156 KB Output is correct
19 Correct 16 ms 2252 KB Output is correct
20 Correct 17 ms 2204 KB Output is correct
21 Correct 38 ms 2252 KB Output is correct
22 Correct 43 ms 2280 KB Output is correct
23 Correct 30 ms 2204 KB Output is correct
24 Correct 53 ms 2240 KB Output is correct
25 Correct 52 ms 2316 KB Output is correct
26 Correct 56 ms 2244 KB Output is correct
27 Correct 56 ms 2296 KB Output is correct
28 Correct 62 ms 2312 KB Output is correct
29 Correct 54 ms 2192 KB Output is correct
30 Correct 55 ms 2276 KB Output is correct
31 Correct 55 ms 2320 KB Output is correct
32 Correct 57 ms 2280 KB Output is correct
33 Correct 57 ms 2300 KB Output is correct
34 Correct 57 ms 2244 KB Output is correct
35 Correct 56 ms 2316 KB Output is correct
36 Correct 57 ms 2244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 1 ms 1208 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 7 ms 2248 KB Output is correct
6 Correct 5 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 8 ms 2252 KB Output is correct
9 Correct 6 ms 2252 KB Output is correct
10 Correct 18 ms 2252 KB Output is correct
11 Correct 21 ms 2268 KB Output is correct
12 Correct 19 ms 2280 KB Output is correct
13 Correct 16 ms 2284 KB Output is correct
14 Correct 16 ms 2232 KB Output is correct
15 Correct 18 ms 2244 KB Output is correct
16 Correct 19 ms 2244 KB Output is correct
17 Correct 12 ms 2240 KB Output is correct
18 Correct 15 ms 2156 KB Output is correct
19 Correct 16 ms 2252 KB Output is correct
20 Correct 17 ms 2204 KB Output is correct
21 Correct 38 ms 2252 KB Output is correct
22 Correct 43 ms 2280 KB Output is correct
23 Correct 30 ms 2204 KB Output is correct
24 Correct 53 ms 2240 KB Output is correct
25 Correct 52 ms 2316 KB Output is correct
26 Correct 56 ms 2244 KB Output is correct
27 Correct 56 ms 2296 KB Output is correct
28 Correct 62 ms 2312 KB Output is correct
29 Correct 54 ms 2192 KB Output is correct
30 Correct 55 ms 2276 KB Output is correct
31 Correct 55 ms 2320 KB Output is correct
32 Correct 57 ms 2280 KB Output is correct
33 Correct 57 ms 2300 KB Output is correct
34 Correct 57 ms 2244 KB Output is correct
35 Correct 56 ms 2316 KB Output is correct
36 Correct 57 ms 2244 KB Output is correct
37 Correct 116 ms 2460 KB Output is correct
38 Correct 116 ms 2448 KB Output is correct
39 Correct 136 ms 2436 KB Output is correct
40 Correct 164 ms 2560 KB Output is correct
41 Correct 147 ms 2544 KB Output is correct
42 Correct 184 ms 2560 KB Output is correct
43 Correct 159 ms 2920 KB Output is correct
44 Correct 165 ms 2820 KB Output is correct
45 Correct 179 ms 2864 KB Output is correct
46 Correct 160 ms 2440 KB Output is correct
47 Correct 157 ms 2500 KB Output is correct
48 Correct 162 ms 2696 KB Output is correct
49 Correct 150 ms 2504 KB Output is correct
50 Correct 162 ms 2628 KB Output is correct
51 Correct 0 ms 328 KB Output is correct
52 Correct 184 ms 2884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 1 ms 1208 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 7 ms 2248 KB Output is correct
6 Correct 5 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 8 ms 2252 KB Output is correct
9 Correct 6 ms 2252 KB Output is correct
10 Correct 18 ms 2252 KB Output is correct
11 Correct 21 ms 2268 KB Output is correct
12 Correct 19 ms 2280 KB Output is correct
13 Correct 16 ms 2284 KB Output is correct
14 Correct 16 ms 2232 KB Output is correct
15 Correct 18 ms 2244 KB Output is correct
16 Correct 19 ms 2244 KB Output is correct
17 Correct 12 ms 2240 KB Output is correct
18 Correct 15 ms 2156 KB Output is correct
19 Correct 16 ms 2252 KB Output is correct
20 Correct 17 ms 2204 KB Output is correct
21 Correct 38 ms 2252 KB Output is correct
22 Correct 43 ms 2280 KB Output is correct
23 Correct 30 ms 2204 KB Output is correct
24 Correct 53 ms 2240 KB Output is correct
25 Correct 52 ms 2316 KB Output is correct
26 Correct 56 ms 2244 KB Output is correct
27 Correct 56 ms 2296 KB Output is correct
28 Correct 62 ms 2312 KB Output is correct
29 Correct 54 ms 2192 KB Output is correct
30 Correct 55 ms 2276 KB Output is correct
31 Correct 55 ms 2320 KB Output is correct
32 Correct 57 ms 2280 KB Output is correct
33 Correct 57 ms 2300 KB Output is correct
34 Correct 57 ms 2244 KB Output is correct
35 Correct 56 ms 2316 KB Output is correct
36 Correct 57 ms 2244 KB Output is correct
37 Correct 116 ms 2460 KB Output is correct
38 Correct 116 ms 2448 KB Output is correct
39 Correct 136 ms 2436 KB Output is correct
40 Correct 164 ms 2560 KB Output is correct
41 Correct 147 ms 2544 KB Output is correct
42 Correct 184 ms 2560 KB Output is correct
43 Correct 159 ms 2920 KB Output is correct
44 Correct 165 ms 2820 KB Output is correct
45 Correct 179 ms 2864 KB Output is correct
46 Correct 160 ms 2440 KB Output is correct
47 Correct 157 ms 2500 KB Output is correct
48 Correct 162 ms 2696 KB Output is correct
49 Correct 150 ms 2504 KB Output is correct
50 Correct 162 ms 2628 KB Output is correct
51 Correct 0 ms 328 KB Output is correct
52 Correct 184 ms 2884 KB Output is correct
53 Correct 192 ms 2688 KB Output is correct
54 Correct 243 ms 2924 KB Output is correct
55 Correct 272 ms 3252 KB Output is correct
56 Correct 203 ms 2820 KB Output is correct
57 Correct 285 ms 3264 KB Output is correct
58 Correct 238 ms 2884 KB Output is correct
59 Correct 259 ms 3008 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 263 ms 3136 KB Output is correct
62 Correct 251 ms 3148 KB Output is correct
63 Correct 248 ms 3272 KB Output is correct
64 Correct 250 ms 3212 KB Output is correct
65 Correct 176 ms 2576 KB Output is correct
66 Correct 169 ms 2500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 1 ms 1208 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 7 ms 2248 KB Output is correct
6 Correct 5 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 8 ms 2252 KB Output is correct
9 Correct 6 ms 2252 KB Output is correct
10 Correct 18 ms 2252 KB Output is correct
11 Correct 21 ms 2268 KB Output is correct
12 Correct 19 ms 2280 KB Output is correct
13 Correct 16 ms 2284 KB Output is correct
14 Correct 16 ms 2232 KB Output is correct
15 Correct 18 ms 2244 KB Output is correct
16 Correct 19 ms 2244 KB Output is correct
17 Correct 12 ms 2240 KB Output is correct
18 Correct 15 ms 2156 KB Output is correct
19 Correct 16 ms 2252 KB Output is correct
20 Correct 17 ms 2204 KB Output is correct
21 Correct 38 ms 2252 KB Output is correct
22 Correct 43 ms 2280 KB Output is correct
23 Correct 30 ms 2204 KB Output is correct
24 Correct 53 ms 2240 KB Output is correct
25 Correct 52 ms 2316 KB Output is correct
26 Correct 56 ms 2244 KB Output is correct
27 Correct 56 ms 2296 KB Output is correct
28 Correct 62 ms 2312 KB Output is correct
29 Correct 54 ms 2192 KB Output is correct
30 Correct 55 ms 2276 KB Output is correct
31 Correct 55 ms 2320 KB Output is correct
32 Correct 57 ms 2280 KB Output is correct
33 Correct 57 ms 2300 KB Output is correct
34 Correct 57 ms 2244 KB Output is correct
35 Correct 56 ms 2316 KB Output is correct
36 Correct 57 ms 2244 KB Output is correct
37 Correct 116 ms 2460 KB Output is correct
38 Correct 116 ms 2448 KB Output is correct
39 Correct 136 ms 2436 KB Output is correct
40 Correct 164 ms 2560 KB Output is correct
41 Correct 147 ms 2544 KB Output is correct
42 Correct 184 ms 2560 KB Output is correct
43 Correct 159 ms 2920 KB Output is correct
44 Correct 165 ms 2820 KB Output is correct
45 Correct 179 ms 2864 KB Output is correct
46 Correct 160 ms 2440 KB Output is correct
47 Correct 157 ms 2500 KB Output is correct
48 Correct 162 ms 2696 KB Output is correct
49 Correct 150 ms 2504 KB Output is correct
50 Correct 162 ms 2628 KB Output is correct
51 Correct 0 ms 328 KB Output is correct
52 Correct 184 ms 2884 KB Output is correct
53 Correct 192 ms 2688 KB Output is correct
54 Correct 243 ms 2924 KB Output is correct
55 Correct 272 ms 3252 KB Output is correct
56 Correct 203 ms 2820 KB Output is correct
57 Correct 285 ms 3264 KB Output is correct
58 Correct 238 ms 2884 KB Output is correct
59 Correct 259 ms 3008 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 263 ms 3136 KB Output is correct
62 Correct 251 ms 3148 KB Output is correct
63 Correct 248 ms 3272 KB Output is correct
64 Correct 250 ms 3212 KB Output is correct
65 Correct 176 ms 2576 KB Output is correct
66 Correct 169 ms 2500 KB Output is correct
67 Correct 291 ms 3204 KB Output is correct
68 Correct 101 ms 1284 KB Output is correct
69 Correct 530 ms 4236 KB Output is correct
70 Correct 415 ms 3596 KB Output is correct
71 Correct 429 ms 3512 KB Output is correct
72 Correct 411 ms 2748 KB Output is correct
73 Correct 423 ms 2756 KB Output is correct
74 Correct 525 ms 4292 KB Output is correct
75 Correct 478 ms 3972 KB Output is correct
76 Correct 534 ms 4476 KB Output is correct
77 Correct 539 ms 4484 KB Output is correct