Submission #171618

# Submission time Handle Problem Language Result Execution time Memory
171618 2019-12-29T12:00:16 Z juggernaut Bootfall (IZhO17_bootfall) C++14
100 / 100
413 ms 4320 KB
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,a[500],dp[250001],i,j,sum,mx=250000;
bool can[250001];
void add(int v){
    for(int j=sum;j>=0;j--)dp[j+v]+=dp[j];
    sum+=v;
}
void del(int v){
    sum-=v;
    for(int j=0;j<=sum;j++)dp[j+v]-=dp[j];
}
vector<int>ans;
main(){
    dp[0]=1;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
        add(a[i]);
    }
    if(sum&1||!dp[sum/2]){
        puts("0");
        return 0;
    }
    for(i=0;i<n;i++){
        del(a[i]);
        for(j=1;j<=mx;j++)if(((sum+j)&1)||!dp[(sum+j)/2])can[j]=1;
        add(a[i]);
    }
    for(i=1;i<=mx;i++)if(!can[i])ans.push_back(i);
    printf("%lld\n",(int)ans.size());
    for(auto res:ans)printf("%lld ",res);
}

Compilation message

bootfall.cpp:16:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
bootfall.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 5 ms 500 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 6 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 5 ms 500 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 6 ms 632 KB Output is correct
10 Correct 12 ms 496 KB Output is correct
11 Correct 11 ms 504 KB Output is correct
12 Correct 12 ms 632 KB Output is correct
13 Correct 11 ms 632 KB Output is correct
14 Correct 12 ms 636 KB Output is correct
15 Correct 12 ms 504 KB Output is correct
16 Correct 11 ms 504 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 10 ms 504 KB Output is correct
19 Correct 11 ms 632 KB Output is correct
20 Correct 12 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 5 ms 500 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 6 ms 632 KB Output is correct
10 Correct 12 ms 496 KB Output is correct
11 Correct 11 ms 504 KB Output is correct
12 Correct 12 ms 632 KB Output is correct
13 Correct 11 ms 632 KB Output is correct
14 Correct 12 ms 636 KB Output is correct
15 Correct 12 ms 504 KB Output is correct
16 Correct 11 ms 504 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 10 ms 504 KB Output is correct
19 Correct 11 ms 632 KB Output is correct
20 Correct 12 ms 632 KB Output is correct
21 Correct 22 ms 632 KB Output is correct
22 Correct 25 ms 680 KB Output is correct
23 Correct 17 ms 632 KB Output is correct
24 Correct 30 ms 636 KB Output is correct
25 Correct 32 ms 632 KB Output is correct
26 Correct 33 ms 788 KB Output is correct
27 Correct 33 ms 760 KB Output is correct
28 Correct 33 ms 760 KB Output is correct
29 Correct 33 ms 632 KB Output is correct
30 Correct 32 ms 632 KB Output is correct
31 Correct 33 ms 760 KB Output is correct
32 Correct 33 ms 648 KB Output is correct
33 Correct 33 ms 632 KB Output is correct
34 Correct 33 ms 632 KB Output is correct
35 Correct 33 ms 632 KB Output is correct
36 Correct 32 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 5 ms 500 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 6 ms 632 KB Output is correct
10 Correct 12 ms 496 KB Output is correct
11 Correct 11 ms 504 KB Output is correct
12 Correct 12 ms 632 KB Output is correct
13 Correct 11 ms 632 KB Output is correct
14 Correct 12 ms 636 KB Output is correct
15 Correct 12 ms 504 KB Output is correct
16 Correct 11 ms 504 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 10 ms 504 KB Output is correct
19 Correct 11 ms 632 KB Output is correct
20 Correct 12 ms 632 KB Output is correct
21 Correct 22 ms 632 KB Output is correct
22 Correct 25 ms 680 KB Output is correct
23 Correct 17 ms 632 KB Output is correct
24 Correct 30 ms 636 KB Output is correct
25 Correct 32 ms 632 KB Output is correct
26 Correct 33 ms 788 KB Output is correct
27 Correct 33 ms 760 KB Output is correct
28 Correct 33 ms 760 KB Output is correct
29 Correct 33 ms 632 KB Output is correct
30 Correct 32 ms 632 KB Output is correct
31 Correct 33 ms 760 KB Output is correct
32 Correct 33 ms 648 KB Output is correct
33 Correct 33 ms 632 KB Output is correct
34 Correct 33 ms 632 KB Output is correct
35 Correct 33 ms 632 KB Output is correct
36 Correct 32 ms 632 KB Output is correct
37 Correct 68 ms 1016 KB Output is correct
38 Correct 69 ms 1056 KB Output is correct
39 Correct 105 ms 1016 KB Output is correct
40 Correct 98 ms 1120 KB Output is correct
41 Correct 119 ms 1272 KB Output is correct
42 Correct 90 ms 1144 KB Output is correct
43 Correct 102 ms 1432 KB Output is correct
44 Correct 104 ms 1524 KB Output is correct
45 Correct 105 ms 1524 KB Output is correct
46 Correct 96 ms 916 KB Output is correct
47 Correct 91 ms 1364 KB Output is correct
48 Correct 109 ms 1528 KB Output is correct
49 Correct 106 ms 1144 KB Output is correct
50 Correct 91 ms 1148 KB Output is correct
51 Correct 6 ms 632 KB Output is correct
52 Correct 121 ms 1704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 5 ms 500 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 6 ms 632 KB Output is correct
10 Correct 12 ms 496 KB Output is correct
11 Correct 11 ms 504 KB Output is correct
12 Correct 12 ms 632 KB Output is correct
13 Correct 11 ms 632 KB Output is correct
14 Correct 12 ms 636 KB Output is correct
15 Correct 12 ms 504 KB Output is correct
16 Correct 11 ms 504 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 10 ms 504 KB Output is correct
19 Correct 11 ms 632 KB Output is correct
20 Correct 12 ms 632 KB Output is correct
21 Correct 22 ms 632 KB Output is correct
22 Correct 25 ms 680 KB Output is correct
23 Correct 17 ms 632 KB Output is correct
24 Correct 30 ms 636 KB Output is correct
25 Correct 32 ms 632 KB Output is correct
26 Correct 33 ms 788 KB Output is correct
27 Correct 33 ms 760 KB Output is correct
28 Correct 33 ms 760 KB Output is correct
29 Correct 33 ms 632 KB Output is correct
30 Correct 32 ms 632 KB Output is correct
31 Correct 33 ms 760 KB Output is correct
32 Correct 33 ms 648 KB Output is correct
33 Correct 33 ms 632 KB Output is correct
34 Correct 33 ms 632 KB Output is correct
35 Correct 33 ms 632 KB Output is correct
36 Correct 32 ms 632 KB Output is correct
37 Correct 68 ms 1016 KB Output is correct
38 Correct 69 ms 1056 KB Output is correct
39 Correct 105 ms 1016 KB Output is correct
40 Correct 98 ms 1120 KB Output is correct
41 Correct 119 ms 1272 KB Output is correct
42 Correct 90 ms 1144 KB Output is correct
43 Correct 102 ms 1432 KB Output is correct
44 Correct 104 ms 1524 KB Output is correct
45 Correct 105 ms 1524 KB Output is correct
46 Correct 96 ms 916 KB Output is correct
47 Correct 91 ms 1364 KB Output is correct
48 Correct 109 ms 1528 KB Output is correct
49 Correct 106 ms 1144 KB Output is correct
50 Correct 91 ms 1148 KB Output is correct
51 Correct 6 ms 632 KB Output is correct
52 Correct 121 ms 1704 KB Output is correct
53 Correct 117 ms 1384 KB Output is correct
54 Correct 143 ms 1524 KB Output is correct
55 Correct 186 ms 2288 KB Output is correct
56 Correct 126 ms 1556 KB Output is correct
57 Correct 192 ms 2380 KB Output is correct
58 Correct 148 ms 1652 KB Output is correct
59 Correct 160 ms 1904 KB Output is correct
60 Correct 14 ms 888 KB Output is correct
61 Correct 170 ms 2004 KB Output is correct
62 Correct 165 ms 2160 KB Output is correct
63 Correct 167 ms 2184 KB Output is correct
64 Correct 163 ms 2176 KB Output is correct
65 Correct 129 ms 1016 KB Output is correct
66 Correct 130 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 5 ms 500 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 6 ms 632 KB Output is correct
10 Correct 12 ms 496 KB Output is correct
11 Correct 11 ms 504 KB Output is correct
12 Correct 12 ms 632 KB Output is correct
13 Correct 11 ms 632 KB Output is correct
14 Correct 12 ms 636 KB Output is correct
15 Correct 12 ms 504 KB Output is correct
16 Correct 11 ms 504 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 10 ms 504 KB Output is correct
19 Correct 11 ms 632 KB Output is correct
20 Correct 12 ms 632 KB Output is correct
21 Correct 22 ms 632 KB Output is correct
22 Correct 25 ms 680 KB Output is correct
23 Correct 17 ms 632 KB Output is correct
24 Correct 30 ms 636 KB Output is correct
25 Correct 32 ms 632 KB Output is correct
26 Correct 33 ms 788 KB Output is correct
27 Correct 33 ms 760 KB Output is correct
28 Correct 33 ms 760 KB Output is correct
29 Correct 33 ms 632 KB Output is correct
30 Correct 32 ms 632 KB Output is correct
31 Correct 33 ms 760 KB Output is correct
32 Correct 33 ms 648 KB Output is correct
33 Correct 33 ms 632 KB Output is correct
34 Correct 33 ms 632 KB Output is correct
35 Correct 33 ms 632 KB Output is correct
36 Correct 32 ms 632 KB Output is correct
37 Correct 68 ms 1016 KB Output is correct
38 Correct 69 ms 1056 KB Output is correct
39 Correct 105 ms 1016 KB Output is correct
40 Correct 98 ms 1120 KB Output is correct
41 Correct 119 ms 1272 KB Output is correct
42 Correct 90 ms 1144 KB Output is correct
43 Correct 102 ms 1432 KB Output is correct
44 Correct 104 ms 1524 KB Output is correct
45 Correct 105 ms 1524 KB Output is correct
46 Correct 96 ms 916 KB Output is correct
47 Correct 91 ms 1364 KB Output is correct
48 Correct 109 ms 1528 KB Output is correct
49 Correct 106 ms 1144 KB Output is correct
50 Correct 91 ms 1148 KB Output is correct
51 Correct 6 ms 632 KB Output is correct
52 Correct 121 ms 1704 KB Output is correct
53 Correct 117 ms 1384 KB Output is correct
54 Correct 143 ms 1524 KB Output is correct
55 Correct 186 ms 2288 KB Output is correct
56 Correct 126 ms 1556 KB Output is correct
57 Correct 192 ms 2380 KB Output is correct
58 Correct 148 ms 1652 KB Output is correct
59 Correct 160 ms 1904 KB Output is correct
60 Correct 14 ms 888 KB Output is correct
61 Correct 170 ms 2004 KB Output is correct
62 Correct 165 ms 2160 KB Output is correct
63 Correct 167 ms 2184 KB Output is correct
64 Correct 163 ms 2176 KB Output is correct
65 Correct 129 ms 1016 KB Output is correct
66 Correct 130 ms 1152 KB Output is correct
67 Correct 181 ms 1904 KB Output is correct
68 Correct 31 ms 1272 KB Output is correct
69 Correct 378 ms 3800 KB Output is correct
70 Correct 285 ms 2544 KB Output is correct
71 Correct 279 ms 2544 KB Output is correct
72 Correct 277 ms 1528 KB Output is correct
73 Correct 273 ms 1528 KB Output is correct
74 Correct 388 ms 4200 KB Output is correct
75 Correct 333 ms 3304 KB Output is correct
76 Correct 413 ms 4320 KB Output is correct
77 Correct 404 ms 4200 KB Output is correct