Submission #678388

# Submission time Handle Problem Language Result Execution time Memory
678388 2023-01-05T17:41:29 Z Ahmed57 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 3620 KB
#include <bits/stdc++.h>

using namespace std;
long long dp[2*500*500+1];
long long mod = int(1e9+7);
bitset<2*500*500+1> su;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int arr[n] , sum = 0;
    for(int i = 0;i<n;i++){
        cin>>arr[i];sum+=arr[i];
    }
    dp[0] = 1;
    for(int i = 0;i<n;i++){
        for(int j = 2*sum;j>=arr[i];j--){
            dp[j]+=dp[j-arr[i]];
            if(dp[j]>=1e18)dp[j]%=mod;
        }
    }
    if(sum%2||(!dp[sum/2])){
        cout<<"0";
        return 0;
    }
    for(int i = 1;i<=sum;i++){su[i] = 1;}
    for(int it = 0;it<n;it++){
        for(int j = arr[it];j<=2*sum;j++){
            dp[j]-=dp[j-arr[it]];
            dp[j]%=mod;
            if(dp[j]<0){dp[j]%=mod;dp[j]+=mod;dp[j]%=mod;}
        }
        for(int j = 1;j<=sum;j++){
            if((sum-arr[it]+j)%2){
                su[j] = 0;
                continue;
            }
            int ne = sum-arr[it]+j;
            int d = (dp[ne/2]>0);
            if(j<=ne/2)d|=(dp[(ne/2)-j]>0);
            if(d==0)su[j] = 0;
        }
        for(int j = 2*sum;j>=arr[it];j--){
            dp[j]+=dp[j-arr[it]];
            if(dp[j]>=1e18)dp[j]%=mod;
        }
    }
    cout<<su.count()<<"\n";
    for(int i = 1;i<=sum;i++)if(su[i])cout<<i<<" ";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 4 ms 380 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 8 ms 340 KB Output is correct
25 Correct 14 ms 468 KB Output is correct
26 Correct 16 ms 472 KB Output is correct
27 Correct 14 ms 472 KB Output is correct
28 Correct 15 ms 480 KB Output is correct
29 Correct 15 ms 472 KB Output is correct
30 Correct 10 ms 340 KB Output is correct
31 Correct 13 ms 452 KB Output is correct
32 Correct 8 ms 408 KB Output is correct
33 Correct 16 ms 468 KB Output is correct
34 Correct 15 ms 488 KB Output is correct
35 Correct 16 ms 468 KB Output is correct
36 Correct 8 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 4 ms 380 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 8 ms 340 KB Output is correct
25 Correct 14 ms 468 KB Output is correct
26 Correct 16 ms 472 KB Output is correct
27 Correct 14 ms 472 KB Output is correct
28 Correct 15 ms 480 KB Output is correct
29 Correct 15 ms 472 KB Output is correct
30 Correct 10 ms 340 KB Output is correct
31 Correct 13 ms 452 KB Output is correct
32 Correct 8 ms 408 KB Output is correct
33 Correct 16 ms 468 KB Output is correct
34 Correct 15 ms 488 KB Output is correct
35 Correct 16 ms 468 KB Output is correct
36 Correct 8 ms 340 KB Output is correct
37 Correct 68 ms 616 KB Output is correct
38 Correct 69 ms 620 KB Output is correct
39 Correct 225 ms 1236 KB Output is correct
40 Correct 150 ms 828 KB Output is correct
41 Correct 289 ms 1464 KB Output is correct
42 Correct 129 ms 780 KB Output is correct
43 Correct 229 ms 1312 KB Output is correct
44 Correct 242 ms 1324 KB Output is correct
45 Correct 239 ms 1336 KB Output is correct
46 Correct 135 ms 828 KB Output is correct
47 Correct 143 ms 972 KB Output is correct
48 Correct 245 ms 1276 KB Output is correct
49 Correct 237 ms 1288 KB Output is correct
50 Correct 144 ms 824 KB Output is correct
51 Correct 25 ms 724 KB Output is correct
52 Correct 312 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 4 ms 380 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 8 ms 340 KB Output is correct
25 Correct 14 ms 468 KB Output is correct
26 Correct 16 ms 472 KB Output is correct
27 Correct 14 ms 472 KB Output is correct
28 Correct 15 ms 480 KB Output is correct
29 Correct 15 ms 472 KB Output is correct
30 Correct 10 ms 340 KB Output is correct
31 Correct 13 ms 452 KB Output is correct
32 Correct 8 ms 408 KB Output is correct
33 Correct 16 ms 468 KB Output is correct
34 Correct 15 ms 488 KB Output is correct
35 Correct 16 ms 468 KB Output is correct
36 Correct 8 ms 340 KB Output is correct
37 Correct 68 ms 616 KB Output is correct
38 Correct 69 ms 620 KB Output is correct
39 Correct 225 ms 1236 KB Output is correct
40 Correct 150 ms 828 KB Output is correct
41 Correct 289 ms 1464 KB Output is correct
42 Correct 129 ms 780 KB Output is correct
43 Correct 229 ms 1312 KB Output is correct
44 Correct 242 ms 1324 KB Output is correct
45 Correct 239 ms 1336 KB Output is correct
46 Correct 135 ms 828 KB Output is correct
47 Correct 143 ms 972 KB Output is correct
48 Correct 245 ms 1276 KB Output is correct
49 Correct 237 ms 1288 KB Output is correct
50 Correct 144 ms 824 KB Output is correct
51 Correct 25 ms 724 KB Output is correct
52 Correct 312 ms 1484 KB Output is correct
53 Correct 236 ms 1148 KB Output is correct
54 Correct 334 ms 1320 KB Output is correct
55 Correct 659 ms 2312 KB Output is correct
56 Correct 290 ms 1320 KB Output is correct
57 Correct 696 ms 2408 KB Output is correct
58 Correct 368 ms 1356 KB Output is correct
59 Correct 459 ms 1640 KB Output is correct
60 Correct 71 ms 1236 KB Output is correct
61 Correct 517 ms 1788 KB Output is correct
62 Correct 518 ms 2076 KB Output is correct
63 Correct 569 ms 2204 KB Output is correct
64 Correct 547 ms 2124 KB Output is correct
65 Correct 223 ms 1064 KB Output is correct
66 Correct 247 ms 1148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 4 ms 380 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 8 ms 340 KB Output is correct
25 Correct 14 ms 468 KB Output is correct
26 Correct 16 ms 472 KB Output is correct
27 Correct 14 ms 472 KB Output is correct
28 Correct 15 ms 480 KB Output is correct
29 Correct 15 ms 472 KB Output is correct
30 Correct 10 ms 340 KB Output is correct
31 Correct 13 ms 452 KB Output is correct
32 Correct 8 ms 408 KB Output is correct
33 Correct 16 ms 468 KB Output is correct
34 Correct 15 ms 488 KB Output is correct
35 Correct 16 ms 468 KB Output is correct
36 Correct 8 ms 340 KB Output is correct
37 Correct 68 ms 616 KB Output is correct
38 Correct 69 ms 620 KB Output is correct
39 Correct 225 ms 1236 KB Output is correct
40 Correct 150 ms 828 KB Output is correct
41 Correct 289 ms 1464 KB Output is correct
42 Correct 129 ms 780 KB Output is correct
43 Correct 229 ms 1312 KB Output is correct
44 Correct 242 ms 1324 KB Output is correct
45 Correct 239 ms 1336 KB Output is correct
46 Correct 135 ms 828 KB Output is correct
47 Correct 143 ms 972 KB Output is correct
48 Correct 245 ms 1276 KB Output is correct
49 Correct 237 ms 1288 KB Output is correct
50 Correct 144 ms 824 KB Output is correct
51 Correct 25 ms 724 KB Output is correct
52 Correct 312 ms 1484 KB Output is correct
53 Correct 236 ms 1148 KB Output is correct
54 Correct 334 ms 1320 KB Output is correct
55 Correct 659 ms 2312 KB Output is correct
56 Correct 290 ms 1320 KB Output is correct
57 Correct 696 ms 2408 KB Output is correct
58 Correct 368 ms 1356 KB Output is correct
59 Correct 459 ms 1640 KB Output is correct
60 Correct 71 ms 1236 KB Output is correct
61 Correct 517 ms 1788 KB Output is correct
62 Correct 518 ms 2076 KB Output is correct
63 Correct 569 ms 2204 KB Output is correct
64 Correct 547 ms 2124 KB Output is correct
65 Correct 223 ms 1064 KB Output is correct
66 Correct 247 ms 1148 KB Output is correct
67 Correct 519 ms 1700 KB Output is correct
68 Correct 162 ms 2240 KB Output is correct
69 Execution timed out 1084 ms 3620 KB Time limit exceeded
70 Halted 0 ms 0 KB -