Submission #534762

# Submission time Handle Problem Language Result Execution time Memory
534762 2022-03-08T20:03:36 Z fadi57 Bootfall (IZhO17_bootfall) C++14
100 / 100
473 ms 5764 KB
#include<bits/stdc++.h>
using namespace std;
const int mx=3e5+900;
const int mx2=1e6+9;
typedef long long ll;
const int mod=998244353 ;
const int SQ=400;
const ll inf=1e9+10;
ll dp[mx],sum,freq[mx],a[mx];
int main(){

      int t;t=1;
      while(t--){
        int n;
      cin>>n;
      dp[0]=1;
      int last=0;
      for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
      }
      sort(a+1,a+n+1);
      for(int i=1;i<=n;i++){
           for(int j=mx-5;j>=a[i];j--){
            dp[j]+=dp[j-a[i]];
         }
        }
        if(sum%2!=0||dp[sum/2]==0){
         cout<<0;
         return 0;
        }
      for(int i=1;i<=n;i++){
          for(int j=a[i];j<=mx-5;j++){
            dp[j]-=dp[j-a[i]];
          }
          sum-=a[i];
          for(int summ=0;summ<=mx-5;summ++){
            if(dp[summ]){
                int rest=sum-summ;
                if(rest-summ<0){continue;}
                freq[rest-summ]++;
            }
          }
          for(int j=mx-5;j>=a[i];j--){
            dp[j]+=dp[j-a[i]];
          }
           sum+=a[i];

      }
      vector<int >ans;
      for(int i = 0; i <= mx-5; i++){
		if(freq[i] == n){
			ans.push_back(i);
		}
	}
	cout << ans.size() << endl;
	for(auto it : ans)
		cout << it << " ";

   }
}








Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:17:11: warning: unused variable 'last' [-Wunused-variable]
   17 |       int last=0;
      |           ^~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2628 KB Output is correct
2 Correct 8 ms 2592 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 6 ms 2668 KB Output is correct
5 Correct 11 ms 2604 KB Output is correct
6 Correct 9 ms 2672 KB Output is correct
7 Correct 8 ms 2636 KB Output is correct
8 Correct 12 ms 2672 KB Output is correct
9 Correct 11 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2628 KB Output is correct
2 Correct 8 ms 2592 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 6 ms 2668 KB Output is correct
5 Correct 11 ms 2604 KB Output is correct
6 Correct 9 ms 2672 KB Output is correct
7 Correct 8 ms 2636 KB Output is correct
8 Correct 12 ms 2672 KB Output is correct
9 Correct 11 ms 2636 KB Output is correct
10 Correct 25 ms 2636 KB Output is correct
11 Correct 27 ms 2608 KB Output is correct
12 Correct 34 ms 2656 KB Output is correct
13 Correct 23 ms 2664 KB Output is correct
14 Correct 24 ms 2636 KB Output is correct
15 Correct 26 ms 2608 KB Output is correct
16 Correct 31 ms 2656 KB Output is correct
17 Correct 18 ms 2664 KB Output is correct
18 Correct 21 ms 2636 KB Output is correct
19 Correct 22 ms 2660 KB Output is correct
20 Correct 25 ms 2604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2628 KB Output is correct
2 Correct 8 ms 2592 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 6 ms 2668 KB Output is correct
5 Correct 11 ms 2604 KB Output is correct
6 Correct 9 ms 2672 KB Output is correct
7 Correct 8 ms 2636 KB Output is correct
8 Correct 12 ms 2672 KB Output is correct
9 Correct 11 ms 2636 KB Output is correct
10 Correct 25 ms 2636 KB Output is correct
11 Correct 27 ms 2608 KB Output is correct
12 Correct 34 ms 2656 KB Output is correct
13 Correct 23 ms 2664 KB Output is correct
14 Correct 24 ms 2636 KB Output is correct
15 Correct 26 ms 2608 KB Output is correct
16 Correct 31 ms 2656 KB Output is correct
17 Correct 18 ms 2664 KB Output is correct
18 Correct 21 ms 2636 KB Output is correct
19 Correct 22 ms 2660 KB Output is correct
20 Correct 25 ms 2604 KB Output is correct
21 Correct 50 ms 2664 KB Output is correct
22 Correct 59 ms 2684 KB Output is correct
23 Correct 56 ms 2672 KB Output is correct
24 Correct 80 ms 2676 KB Output is correct
25 Correct 72 ms 2712 KB Output is correct
26 Correct 78 ms 2728 KB Output is correct
27 Correct 74 ms 2636 KB Output is correct
28 Correct 102 ms 2720 KB Output is correct
29 Correct 102 ms 2716 KB Output is correct
30 Correct 74 ms 2688 KB Output is correct
31 Correct 75 ms 2756 KB Output is correct
32 Correct 87 ms 2676 KB Output is correct
33 Correct 87 ms 2648 KB Output is correct
34 Correct 78 ms 2648 KB Output is correct
35 Correct 74 ms 2636 KB Output is correct
36 Correct 106 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2628 KB Output is correct
2 Correct 8 ms 2592 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 6 ms 2668 KB Output is correct
5 Correct 11 ms 2604 KB Output is correct
6 Correct 9 ms 2672 KB Output is correct
7 Correct 8 ms 2636 KB Output is correct
8 Correct 12 ms 2672 KB Output is correct
9 Correct 11 ms 2636 KB Output is correct
10 Correct 25 ms 2636 KB Output is correct
11 Correct 27 ms 2608 KB Output is correct
12 Correct 34 ms 2656 KB Output is correct
13 Correct 23 ms 2664 KB Output is correct
14 Correct 24 ms 2636 KB Output is correct
15 Correct 26 ms 2608 KB Output is correct
16 Correct 31 ms 2656 KB Output is correct
17 Correct 18 ms 2664 KB Output is correct
18 Correct 21 ms 2636 KB Output is correct
19 Correct 22 ms 2660 KB Output is correct
20 Correct 25 ms 2604 KB Output is correct
21 Correct 50 ms 2664 KB Output is correct
22 Correct 59 ms 2684 KB Output is correct
23 Correct 56 ms 2672 KB Output is correct
24 Correct 80 ms 2676 KB Output is correct
25 Correct 72 ms 2712 KB Output is correct
26 Correct 78 ms 2728 KB Output is correct
27 Correct 74 ms 2636 KB Output is correct
28 Correct 102 ms 2720 KB Output is correct
29 Correct 102 ms 2716 KB Output is correct
30 Correct 74 ms 2688 KB Output is correct
31 Correct 75 ms 2756 KB Output is correct
32 Correct 87 ms 2676 KB Output is correct
33 Correct 87 ms 2648 KB Output is correct
34 Correct 78 ms 2648 KB Output is correct
35 Correct 74 ms 2636 KB Output is correct
36 Correct 106 ms 2636 KB Output is correct
37 Correct 166 ms 3040 KB Output is correct
38 Correct 143 ms 2928 KB Output is correct
39 Correct 188 ms 3124 KB Output is correct
40 Correct 213 ms 3024 KB Output is correct
41 Correct 229 ms 3144 KB Output is correct
42 Correct 221 ms 3008 KB Output is correct
43 Correct 183 ms 3408 KB Output is correct
44 Correct 188 ms 3468 KB Output is correct
45 Correct 214 ms 3396 KB Output is correct
46 Correct 192 ms 2884 KB Output is correct
47 Correct 205 ms 3036 KB Output is correct
48 Correct 222 ms 3412 KB Output is correct
49 Correct 195 ms 3128 KB Output is correct
50 Correct 239 ms 3024 KB Output is correct
51 Correct 39 ms 2636 KB Output is correct
52 Correct 207 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2628 KB Output is correct
2 Correct 8 ms 2592 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 6 ms 2668 KB Output is correct
5 Correct 11 ms 2604 KB Output is correct
6 Correct 9 ms 2672 KB Output is correct
7 Correct 8 ms 2636 KB Output is correct
8 Correct 12 ms 2672 KB Output is correct
9 Correct 11 ms 2636 KB Output is correct
10 Correct 25 ms 2636 KB Output is correct
11 Correct 27 ms 2608 KB Output is correct
12 Correct 34 ms 2656 KB Output is correct
13 Correct 23 ms 2664 KB Output is correct
14 Correct 24 ms 2636 KB Output is correct
15 Correct 26 ms 2608 KB Output is correct
16 Correct 31 ms 2656 KB Output is correct
17 Correct 18 ms 2664 KB Output is correct
18 Correct 21 ms 2636 KB Output is correct
19 Correct 22 ms 2660 KB Output is correct
20 Correct 25 ms 2604 KB Output is correct
21 Correct 50 ms 2664 KB Output is correct
22 Correct 59 ms 2684 KB Output is correct
23 Correct 56 ms 2672 KB Output is correct
24 Correct 80 ms 2676 KB Output is correct
25 Correct 72 ms 2712 KB Output is correct
26 Correct 78 ms 2728 KB Output is correct
27 Correct 74 ms 2636 KB Output is correct
28 Correct 102 ms 2720 KB Output is correct
29 Correct 102 ms 2716 KB Output is correct
30 Correct 74 ms 2688 KB Output is correct
31 Correct 75 ms 2756 KB Output is correct
32 Correct 87 ms 2676 KB Output is correct
33 Correct 87 ms 2648 KB Output is correct
34 Correct 78 ms 2648 KB Output is correct
35 Correct 74 ms 2636 KB Output is correct
36 Correct 106 ms 2636 KB Output is correct
37 Correct 166 ms 3040 KB Output is correct
38 Correct 143 ms 2928 KB Output is correct
39 Correct 188 ms 3124 KB Output is correct
40 Correct 213 ms 3024 KB Output is correct
41 Correct 229 ms 3144 KB Output is correct
42 Correct 221 ms 3008 KB Output is correct
43 Correct 183 ms 3408 KB Output is correct
44 Correct 188 ms 3468 KB Output is correct
45 Correct 214 ms 3396 KB Output is correct
46 Correct 192 ms 2884 KB Output is correct
47 Correct 205 ms 3036 KB Output is correct
48 Correct 222 ms 3412 KB Output is correct
49 Correct 195 ms 3128 KB Output is correct
50 Correct 239 ms 3024 KB Output is correct
51 Correct 39 ms 2636 KB Output is correct
52 Correct 207 ms 3576 KB Output is correct
53 Correct 242 ms 3288 KB Output is correct
54 Correct 288 ms 3396 KB Output is correct
55 Correct 276 ms 4020 KB Output is correct
56 Correct 283 ms 3396 KB Output is correct
57 Correct 267 ms 4192 KB Output is correct
58 Correct 294 ms 3508 KB Output is correct
59 Correct 261 ms 3748 KB Output is correct
60 Correct 52 ms 2636 KB Output is correct
61 Correct 303 ms 3916 KB Output is correct
62 Correct 281 ms 3912 KB Output is correct
63 Correct 305 ms 4084 KB Output is correct
64 Correct 249 ms 4048 KB Output is correct
65 Correct 243 ms 3012 KB Output is correct
66 Correct 294 ms 3056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2628 KB Output is correct
2 Correct 8 ms 2592 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 6 ms 2668 KB Output is correct
5 Correct 11 ms 2604 KB Output is correct
6 Correct 9 ms 2672 KB Output is correct
7 Correct 8 ms 2636 KB Output is correct
8 Correct 12 ms 2672 KB Output is correct
9 Correct 11 ms 2636 KB Output is correct
10 Correct 25 ms 2636 KB Output is correct
11 Correct 27 ms 2608 KB Output is correct
12 Correct 34 ms 2656 KB Output is correct
13 Correct 23 ms 2664 KB Output is correct
14 Correct 24 ms 2636 KB Output is correct
15 Correct 26 ms 2608 KB Output is correct
16 Correct 31 ms 2656 KB Output is correct
17 Correct 18 ms 2664 KB Output is correct
18 Correct 21 ms 2636 KB Output is correct
19 Correct 22 ms 2660 KB Output is correct
20 Correct 25 ms 2604 KB Output is correct
21 Correct 50 ms 2664 KB Output is correct
22 Correct 59 ms 2684 KB Output is correct
23 Correct 56 ms 2672 KB Output is correct
24 Correct 80 ms 2676 KB Output is correct
25 Correct 72 ms 2712 KB Output is correct
26 Correct 78 ms 2728 KB Output is correct
27 Correct 74 ms 2636 KB Output is correct
28 Correct 102 ms 2720 KB Output is correct
29 Correct 102 ms 2716 KB Output is correct
30 Correct 74 ms 2688 KB Output is correct
31 Correct 75 ms 2756 KB Output is correct
32 Correct 87 ms 2676 KB Output is correct
33 Correct 87 ms 2648 KB Output is correct
34 Correct 78 ms 2648 KB Output is correct
35 Correct 74 ms 2636 KB Output is correct
36 Correct 106 ms 2636 KB Output is correct
37 Correct 166 ms 3040 KB Output is correct
38 Correct 143 ms 2928 KB Output is correct
39 Correct 188 ms 3124 KB Output is correct
40 Correct 213 ms 3024 KB Output is correct
41 Correct 229 ms 3144 KB Output is correct
42 Correct 221 ms 3008 KB Output is correct
43 Correct 183 ms 3408 KB Output is correct
44 Correct 188 ms 3468 KB Output is correct
45 Correct 214 ms 3396 KB Output is correct
46 Correct 192 ms 2884 KB Output is correct
47 Correct 205 ms 3036 KB Output is correct
48 Correct 222 ms 3412 KB Output is correct
49 Correct 195 ms 3128 KB Output is correct
50 Correct 239 ms 3024 KB Output is correct
51 Correct 39 ms 2636 KB Output is correct
52 Correct 207 ms 3576 KB Output is correct
53 Correct 242 ms 3288 KB Output is correct
54 Correct 288 ms 3396 KB Output is correct
55 Correct 276 ms 4020 KB Output is correct
56 Correct 283 ms 3396 KB Output is correct
57 Correct 267 ms 4192 KB Output is correct
58 Correct 294 ms 3508 KB Output is correct
59 Correct 261 ms 3748 KB Output is correct
60 Correct 52 ms 2636 KB Output is correct
61 Correct 303 ms 3916 KB Output is correct
62 Correct 281 ms 3912 KB Output is correct
63 Correct 305 ms 4084 KB Output is correct
64 Correct 249 ms 4048 KB Output is correct
65 Correct 243 ms 3012 KB Output is correct
66 Correct 294 ms 3056 KB Output is correct
67 Correct 302 ms 3776 KB Output is correct
68 Correct 82 ms 2636 KB Output is correct
69 Correct 457 ms 5436 KB Output is correct
70 Correct 383 ms 4412 KB Output is correct
71 Correct 414 ms 4304 KB Output is correct
72 Correct 371 ms 3620 KB Output is correct
73 Correct 399 ms 3536 KB Output is correct
74 Correct 384 ms 5536 KB Output is correct
75 Correct 473 ms 5024 KB Output is correct
76 Correct 440 ms 5680 KB Output is correct
77 Correct 400 ms 5764 KB Output is correct