Submission #97608

# Submission time Handle Problem Language Result Execution time Memory
97608 2019-02-17T13:04:35 Z Kalam Bootfall (IZhO17_bootfall) C++11
100 / 100
642 ms 2876 KB
// KALAM
# include<bits/stdc++.h>

using namespace std;

const int N = 450 + 77 , NN = 250077;
unsigned int dp[NN];
bool M[NN];
int n , S , a[N];
inline void Add(int x){
   S += x;
   for(int i = NN - 1;i >= x;-- i)
      dp[i] += dp[i - x];
}
inline void Remove(int x){
   S -= x;
   for(int i = x;i < NN;++ i)
      dp[i] -= dp[i - x];
}
int main() {
   dp[0] = 1;
   for(int i = 1;i < NN;++ i)
      M[i] = 1;
   scanf("%d" , & n);
   for(int i = 1;i <= n;++ i)
      scanf("%d" , a + i) , Add(a[i]);
   if(S % 2 == 1 || dp[S >> 1] == 0)
      return ! printf("0\n");
   for(int i = 1;i <= n;++ i){
      Remove(a[i]);
      for(int j = 1;j < NN;++ j){
         if(S % 2 != j % 2 || j > S){
            M[j] = 0;
            continue ;
         }
         if(dp[(S - j) >> 1] == 0)
            M[j] = 0;
      }
      Add(a[i]);
   }
   vector < int > V;
   for(int i = 1;i < NN;++ i)
      if(M[i])
         V.push_back(i);
   printf("%d\n" , int(V.size()));
   for(int x : V)
      printf("%d " , x);
   return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:24:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d" , & n);
    ~~~~~^~~~~~~~~~~~
bootfall.cpp:26:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d" , a + i) , Add(a[i]);
       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1536 KB Output is correct
2 Correct 16 ms 1580 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 11 ms 1536 KB Output is correct
5 Correct 23 ms 1536 KB Output is correct
6 Correct 21 ms 1536 KB Output is correct
7 Correct 18 ms 1536 KB Output is correct
8 Correct 28 ms 1536 KB Output is correct
9 Correct 19 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1536 KB Output is correct
2 Correct 16 ms 1580 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 11 ms 1536 KB Output is correct
5 Correct 23 ms 1536 KB Output is correct
6 Correct 21 ms 1536 KB Output is correct
7 Correct 18 ms 1536 KB Output is correct
8 Correct 28 ms 1536 KB Output is correct
9 Correct 19 ms 1536 KB Output is correct
10 Correct 55 ms 1596 KB Output is correct
11 Correct 48 ms 1536 KB Output is correct
12 Correct 53 ms 1536 KB Output is correct
13 Correct 50 ms 1536 KB Output is correct
14 Correct 47 ms 1536 KB Output is correct
15 Correct 50 ms 1564 KB Output is correct
16 Correct 54 ms 1624 KB Output is correct
17 Correct 31 ms 1536 KB Output is correct
18 Correct 40 ms 1536 KB Output is correct
19 Correct 51 ms 1512 KB Output is correct
20 Correct 55 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1536 KB Output is correct
2 Correct 16 ms 1580 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 11 ms 1536 KB Output is correct
5 Correct 23 ms 1536 KB Output is correct
6 Correct 21 ms 1536 KB Output is correct
7 Correct 18 ms 1536 KB Output is correct
8 Correct 28 ms 1536 KB Output is correct
9 Correct 19 ms 1536 KB Output is correct
10 Correct 55 ms 1596 KB Output is correct
11 Correct 48 ms 1536 KB Output is correct
12 Correct 53 ms 1536 KB Output is correct
13 Correct 50 ms 1536 KB Output is correct
14 Correct 47 ms 1536 KB Output is correct
15 Correct 50 ms 1564 KB Output is correct
16 Correct 54 ms 1624 KB Output is correct
17 Correct 31 ms 1536 KB Output is correct
18 Correct 40 ms 1536 KB Output is correct
19 Correct 51 ms 1512 KB Output is correct
20 Correct 55 ms 1536 KB Output is correct
21 Correct 102 ms 1620 KB Output is correct
22 Correct 128 ms 1616 KB Output is correct
23 Correct 88 ms 1536 KB Output is correct
24 Correct 165 ms 1628 KB Output is correct
25 Correct 158 ms 1628 KB Output is correct
26 Correct 186 ms 1656 KB Output is correct
27 Correct 172 ms 1616 KB Output is correct
28 Correct 151 ms 1536 KB Output is correct
29 Correct 154 ms 1536 KB Output is correct
30 Correct 156 ms 1656 KB Output is correct
31 Correct 163 ms 1656 KB Output is correct
32 Correct 161 ms 1656 KB Output is correct
33 Correct 150 ms 1592 KB Output is correct
34 Correct 150 ms 1656 KB Output is correct
35 Correct 153 ms 1620 KB Output is correct
36 Correct 158 ms 1592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1536 KB Output is correct
2 Correct 16 ms 1580 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 11 ms 1536 KB Output is correct
5 Correct 23 ms 1536 KB Output is correct
6 Correct 21 ms 1536 KB Output is correct
7 Correct 18 ms 1536 KB Output is correct
8 Correct 28 ms 1536 KB Output is correct
9 Correct 19 ms 1536 KB Output is correct
10 Correct 55 ms 1596 KB Output is correct
11 Correct 48 ms 1536 KB Output is correct
12 Correct 53 ms 1536 KB Output is correct
13 Correct 50 ms 1536 KB Output is correct
14 Correct 47 ms 1536 KB Output is correct
15 Correct 50 ms 1564 KB Output is correct
16 Correct 54 ms 1624 KB Output is correct
17 Correct 31 ms 1536 KB Output is correct
18 Correct 40 ms 1536 KB Output is correct
19 Correct 51 ms 1512 KB Output is correct
20 Correct 55 ms 1536 KB Output is correct
21 Correct 102 ms 1620 KB Output is correct
22 Correct 128 ms 1616 KB Output is correct
23 Correct 88 ms 1536 KB Output is correct
24 Correct 165 ms 1628 KB Output is correct
25 Correct 158 ms 1628 KB Output is correct
26 Correct 186 ms 1656 KB Output is correct
27 Correct 172 ms 1616 KB Output is correct
28 Correct 151 ms 1536 KB Output is correct
29 Correct 154 ms 1536 KB Output is correct
30 Correct 156 ms 1656 KB Output is correct
31 Correct 163 ms 1656 KB Output is correct
32 Correct 161 ms 1656 KB Output is correct
33 Correct 150 ms 1592 KB Output is correct
34 Correct 150 ms 1656 KB Output is correct
35 Correct 153 ms 1620 KB Output is correct
36 Correct 158 ms 1592 KB Output is correct
37 Correct 300 ms 1712 KB Output is correct
38 Correct 309 ms 1748 KB Output is correct
39 Correct 320 ms 1628 KB Output is correct
40 Correct 446 ms 1784 KB Output is correct
41 Correct 359 ms 1584 KB Output is correct
42 Correct 381 ms 1784 KB Output is correct
43 Correct 361 ms 1912 KB Output is correct
44 Correct 404 ms 1884 KB Output is correct
45 Correct 372 ms 2040 KB Output is correct
46 Correct 415 ms 1656 KB Output is correct
47 Correct 404 ms 1784 KB Output is correct
48 Correct 340 ms 1916 KB Output is correct
49 Correct 336 ms 1660 KB Output is correct
50 Correct 383 ms 1784 KB Output is correct
51 Correct 47 ms 1536 KB Output is correct
52 Correct 372 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1536 KB Output is correct
2 Correct 16 ms 1580 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 11 ms 1536 KB Output is correct
5 Correct 23 ms 1536 KB Output is correct
6 Correct 21 ms 1536 KB Output is correct
7 Correct 18 ms 1536 KB Output is correct
8 Correct 28 ms 1536 KB Output is correct
9 Correct 19 ms 1536 KB Output is correct
10 Correct 55 ms 1596 KB Output is correct
11 Correct 48 ms 1536 KB Output is correct
12 Correct 53 ms 1536 KB Output is correct
13 Correct 50 ms 1536 KB Output is correct
14 Correct 47 ms 1536 KB Output is correct
15 Correct 50 ms 1564 KB Output is correct
16 Correct 54 ms 1624 KB Output is correct
17 Correct 31 ms 1536 KB Output is correct
18 Correct 40 ms 1536 KB Output is correct
19 Correct 51 ms 1512 KB Output is correct
20 Correct 55 ms 1536 KB Output is correct
21 Correct 102 ms 1620 KB Output is correct
22 Correct 128 ms 1616 KB Output is correct
23 Correct 88 ms 1536 KB Output is correct
24 Correct 165 ms 1628 KB Output is correct
25 Correct 158 ms 1628 KB Output is correct
26 Correct 186 ms 1656 KB Output is correct
27 Correct 172 ms 1616 KB Output is correct
28 Correct 151 ms 1536 KB Output is correct
29 Correct 154 ms 1536 KB Output is correct
30 Correct 156 ms 1656 KB Output is correct
31 Correct 163 ms 1656 KB Output is correct
32 Correct 161 ms 1656 KB Output is correct
33 Correct 150 ms 1592 KB Output is correct
34 Correct 150 ms 1656 KB Output is correct
35 Correct 153 ms 1620 KB Output is correct
36 Correct 158 ms 1592 KB Output is correct
37 Correct 300 ms 1712 KB Output is correct
38 Correct 309 ms 1748 KB Output is correct
39 Correct 320 ms 1628 KB Output is correct
40 Correct 446 ms 1784 KB Output is correct
41 Correct 359 ms 1584 KB Output is correct
42 Correct 381 ms 1784 KB Output is correct
43 Correct 361 ms 1912 KB Output is correct
44 Correct 404 ms 1884 KB Output is correct
45 Correct 372 ms 2040 KB Output is correct
46 Correct 415 ms 1656 KB Output is correct
47 Correct 404 ms 1784 KB Output is correct
48 Correct 340 ms 1916 KB Output is correct
49 Correct 336 ms 1660 KB Output is correct
50 Correct 383 ms 1784 KB Output is correct
51 Correct 47 ms 1536 KB Output is correct
52 Correct 372 ms 1912 KB Output is correct
53 Correct 415 ms 1884 KB Output is correct
54 Correct 504 ms 2012 KB Output is correct
55 Correct 410 ms 2292 KB Output is correct
56 Correct 425 ms 1912 KB Output is correct
57 Correct 418 ms 2368 KB Output is correct
58 Correct 525 ms 2040 KB Output is correct
59 Correct 504 ms 2164 KB Output is correct
60 Correct 54 ms 1536 KB Output is correct
61 Correct 463 ms 2092 KB Output is correct
62 Correct 410 ms 2136 KB Output is correct
63 Correct 450 ms 2188 KB Output is correct
64 Correct 443 ms 2164 KB Output is correct
65 Correct 468 ms 1536 KB Output is correct
66 Correct 499 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1536 KB Output is correct
2 Correct 16 ms 1580 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 11 ms 1536 KB Output is correct
5 Correct 23 ms 1536 KB Output is correct
6 Correct 21 ms 1536 KB Output is correct
7 Correct 18 ms 1536 KB Output is correct
8 Correct 28 ms 1536 KB Output is correct
9 Correct 19 ms 1536 KB Output is correct
10 Correct 55 ms 1596 KB Output is correct
11 Correct 48 ms 1536 KB Output is correct
12 Correct 53 ms 1536 KB Output is correct
13 Correct 50 ms 1536 KB Output is correct
14 Correct 47 ms 1536 KB Output is correct
15 Correct 50 ms 1564 KB Output is correct
16 Correct 54 ms 1624 KB Output is correct
17 Correct 31 ms 1536 KB Output is correct
18 Correct 40 ms 1536 KB Output is correct
19 Correct 51 ms 1512 KB Output is correct
20 Correct 55 ms 1536 KB Output is correct
21 Correct 102 ms 1620 KB Output is correct
22 Correct 128 ms 1616 KB Output is correct
23 Correct 88 ms 1536 KB Output is correct
24 Correct 165 ms 1628 KB Output is correct
25 Correct 158 ms 1628 KB Output is correct
26 Correct 186 ms 1656 KB Output is correct
27 Correct 172 ms 1616 KB Output is correct
28 Correct 151 ms 1536 KB Output is correct
29 Correct 154 ms 1536 KB Output is correct
30 Correct 156 ms 1656 KB Output is correct
31 Correct 163 ms 1656 KB Output is correct
32 Correct 161 ms 1656 KB Output is correct
33 Correct 150 ms 1592 KB Output is correct
34 Correct 150 ms 1656 KB Output is correct
35 Correct 153 ms 1620 KB Output is correct
36 Correct 158 ms 1592 KB Output is correct
37 Correct 300 ms 1712 KB Output is correct
38 Correct 309 ms 1748 KB Output is correct
39 Correct 320 ms 1628 KB Output is correct
40 Correct 446 ms 1784 KB Output is correct
41 Correct 359 ms 1584 KB Output is correct
42 Correct 381 ms 1784 KB Output is correct
43 Correct 361 ms 1912 KB Output is correct
44 Correct 404 ms 1884 KB Output is correct
45 Correct 372 ms 2040 KB Output is correct
46 Correct 415 ms 1656 KB Output is correct
47 Correct 404 ms 1784 KB Output is correct
48 Correct 340 ms 1916 KB Output is correct
49 Correct 336 ms 1660 KB Output is correct
50 Correct 383 ms 1784 KB Output is correct
51 Correct 47 ms 1536 KB Output is correct
52 Correct 372 ms 1912 KB Output is correct
53 Correct 415 ms 1884 KB Output is correct
54 Correct 504 ms 2012 KB Output is correct
55 Correct 410 ms 2292 KB Output is correct
56 Correct 425 ms 1912 KB Output is correct
57 Correct 418 ms 2368 KB Output is correct
58 Correct 525 ms 2040 KB Output is correct
59 Correct 504 ms 2164 KB Output is correct
60 Correct 54 ms 1536 KB Output is correct
61 Correct 463 ms 2092 KB Output is correct
62 Correct 410 ms 2136 KB Output is correct
63 Correct 450 ms 2188 KB Output is correct
64 Correct 443 ms 2164 KB Output is correct
65 Correct 468 ms 1536 KB Output is correct
66 Correct 499 ms 1628 KB Output is correct
67 Correct 535 ms 2092 KB Output is correct
68 Correct 79 ms 1536 KB Output is correct
69 Correct 538 ms 2732 KB Output is correct
70 Correct 609 ms 2388 KB Output is correct
71 Correct 574 ms 2420 KB Output is correct
72 Correct 642 ms 1628 KB Output is correct
73 Correct 583 ms 1656 KB Output is correct
74 Correct 426 ms 2844 KB Output is correct
75 Correct 575 ms 2672 KB Output is correct
76 Correct 455 ms 2800 KB Output is correct
77 Correct 416 ms 2876 KB Output is correct