Submission #522709

# Submission time Handle Problem Language Result Execution time Memory
522709 2022-02-05T13:37:51 Z dostigator Bootfall (IZhO17_bootfall) C++17
100 / 100
334 ms 3452 KB
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
using namespace std;
#define IShowSpeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcnt __builtin_popcount
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define mii map<int,int>
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define pb push_back
#define vt vector
#define endl '\n'
#define X first
#define Y second
typedef long double ld;
typedef long long ll;
const ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},N=1e6;
const ll mod=1e9+7,inf=1e18;
int dp[N];
int used[N];
void solve(){
    int n;
    cin>>n;
    int a[n+2],sum=0;
    for(int i=1; i<=n; ++i) {cin>>a[i];sum+=a[i];}
    dp[0]=1;
    for(int j=1; j<=n; ++j) for(int i=sum; i>=a[j]; --i) dp[i]+=dp[i-a[j]];
    if(!dp[sum/2] || sum%2){
        cout<<0<<endl;
        return;
    }
    vt<int>res;
    for(int i=1; i<=n; ++i){
        for(int j=a[i]; j<=sum; ++j) dp[j]-=dp[j-a[i]];
        for(int nd=1; nd<=sum; ++nd){
            int h=sum-a[i];
            h+=nd;
            if(h%2 || !dp[h/2]) continue;
            used[nd]++;
            if(used[nd]==n)res.pb(nd);
        }
        for(int j=sum; j>=a[i]; --j) dp[j]+=dp[j-a[i]];
    }
    cout<<res.size()<<endl;
    for(int x:res)cout<<x<<' ';
}
int main() {
    IShowSpeed;
    int tt=1;
    //cin>>tt;
    while(tt--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 404 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 404 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 11 ms 600 KB Output is correct
38 Correct 11 ms 588 KB Output is correct
39 Correct 29 ms 716 KB Output is correct
40 Correct 24 ms 692 KB Output is correct
41 Correct 36 ms 844 KB Output is correct
42 Correct 22 ms 684 KB Output is correct
43 Correct 35 ms 1000 KB Output is correct
44 Correct 38 ms 1128 KB Output is correct
45 Correct 37 ms 1176 KB Output is correct
46 Correct 17 ms 460 KB Output is correct
47 Correct 23 ms 708 KB Output is correct
48 Correct 37 ms 1040 KB Output is correct
49 Correct 34 ms 808 KB Output is correct
50 Correct 23 ms 708 KB Output is correct
51 Correct 2 ms 332 KB Output is correct
52 Correct 47 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 404 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 11 ms 600 KB Output is correct
38 Correct 11 ms 588 KB Output is correct
39 Correct 29 ms 716 KB Output is correct
40 Correct 24 ms 692 KB Output is correct
41 Correct 36 ms 844 KB Output is correct
42 Correct 22 ms 684 KB Output is correct
43 Correct 35 ms 1000 KB Output is correct
44 Correct 38 ms 1128 KB Output is correct
45 Correct 37 ms 1176 KB Output is correct
46 Correct 17 ms 460 KB Output is correct
47 Correct 23 ms 708 KB Output is correct
48 Correct 37 ms 1040 KB Output is correct
49 Correct 34 ms 808 KB Output is correct
50 Correct 23 ms 708 KB Output is correct
51 Correct 2 ms 332 KB Output is correct
52 Correct 47 ms 1252 KB Output is correct
53 Correct 36 ms 924 KB Output is correct
54 Correct 50 ms 1140 KB Output is correct
55 Correct 101 ms 1704 KB Output is correct
56 Correct 46 ms 1132 KB Output is correct
57 Correct 104 ms 1812 KB Output is correct
58 Correct 57 ms 1180 KB Output is correct
59 Correct 69 ms 1428 KB Output is correct
60 Correct 6 ms 460 KB Output is correct
61 Correct 78 ms 1496 KB Output is correct
62 Correct 80 ms 1608 KB Output is correct
63 Correct 85 ms 1720 KB Output is correct
64 Correct 82 ms 1736 KB Output is correct
65 Correct 33 ms 716 KB Output is correct
66 Correct 34 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 404 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 11 ms 600 KB Output is correct
38 Correct 11 ms 588 KB Output is correct
39 Correct 29 ms 716 KB Output is correct
40 Correct 24 ms 692 KB Output is correct
41 Correct 36 ms 844 KB Output is correct
42 Correct 22 ms 684 KB Output is correct
43 Correct 35 ms 1000 KB Output is correct
44 Correct 38 ms 1128 KB Output is correct
45 Correct 37 ms 1176 KB Output is correct
46 Correct 17 ms 460 KB Output is correct
47 Correct 23 ms 708 KB Output is correct
48 Correct 37 ms 1040 KB Output is correct
49 Correct 34 ms 808 KB Output is correct
50 Correct 23 ms 708 KB Output is correct
51 Correct 2 ms 332 KB Output is correct
52 Correct 47 ms 1252 KB Output is correct
53 Correct 36 ms 924 KB Output is correct
54 Correct 50 ms 1140 KB Output is correct
55 Correct 101 ms 1704 KB Output is correct
56 Correct 46 ms 1132 KB Output is correct
57 Correct 104 ms 1812 KB Output is correct
58 Correct 57 ms 1180 KB Output is correct
59 Correct 69 ms 1428 KB Output is correct
60 Correct 6 ms 460 KB Output is correct
61 Correct 78 ms 1496 KB Output is correct
62 Correct 80 ms 1608 KB Output is correct
63 Correct 85 ms 1720 KB Output is correct
64 Correct 82 ms 1736 KB Output is correct
65 Correct 33 ms 716 KB Output is correct
66 Correct 34 ms 736 KB Output is correct
67 Correct 85 ms 1468 KB Output is correct
68 Correct 17 ms 700 KB Output is correct
69 Correct 261 ms 3116 KB Output is correct
70 Correct 166 ms 2096 KB Output is correct
71 Correct 160 ms 2056 KB Output is correct
72 Correct 155 ms 1204 KB Output is correct
73 Correct 154 ms 1348 KB Output is correct
74 Correct 278 ms 3344 KB Output is correct
75 Correct 228 ms 2696 KB Output is correct
76 Correct 300 ms 3372 KB Output is correct
77 Correct 334 ms 3452 KB Output is correct