Submission #499362

# Submission time Handle Problem Language Result Execution time Memory
499362 2021-12-28T05:19:32 Z beksultan04 Bootfall (IZhO17_bootfall) C++14
100 / 100
227 ms 5660 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int a[N],b[N],q[N],dp[N],n,sum;
int used[N];
void add(int x){
    int i;
    for (i=sum;i>=0;--i){
        dp[i+x]+=dp[i];
    }
    ret ;
}
 
void del(int x){
    int i;
    for (i=0;i<=sum;++i){
        dp[i+x]-=dp[i];
    }
    ret ;
}
 
main(){
    int i,j,x;
    scan1(n)
    dp[0]=1;
    for (i=1;i<=n;++i){
        scan1(q[i])
        add(q[i]);
        sum+=q[i];
    }
    
 
    if(sum&1 || !dp[sum/2]){
        cout << 0 << endl;
        return 0;
    }
    for (i=1;i<=n;++i){
        del(q[i]);
        sum-=q[i];
        for (j=sum/2;j<=sum;++j){
            if (dp[j] && j*2 > sum)
                used[j*2-sum]++;
        }
        sum+=q[i];
        add(q[i]);
    }
 
    vector <int> ans;
    for (x=1;x<=sum;++x){
        if (used[x]==n)ans.pb(x);
    }
    cout <<ans.size()<<"\n";
    for (i=0;i<ans.size();++i){
        cout <<ans[i]<<" ";
    }
}
 
 
 

Compilation message

bootfall.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main(){
      | ^~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:65:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (i=0;i<ans.size();++i){
      |              ~^~~~~~~~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
bootfall.cpp:36:5: note: in expansion of macro 'scan1'
   36 |     scan1(n)
      |     ^~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
bootfall.cpp:39:9: note: in expansion of macro 'scan1'
   39 |         scan1(q[i])
      |         ^~~~~
# 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 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 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 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 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 204 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 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 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 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 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 204 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 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 420 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 3 ms 428 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 2 ms 408 KB Output is correct
35 Correct 2 ms 452 KB Output is correct
36 Correct 2 ms 324 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 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 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 204 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 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 420 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 3 ms 428 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 2 ms 408 KB Output is correct
35 Correct 2 ms 452 KB Output is correct
36 Correct 2 ms 324 KB Output is correct
37 Correct 9 ms 844 KB Output is correct
38 Correct 8 ms 844 KB Output is correct
39 Correct 37 ms 1196 KB Output is correct
40 Correct 18 ms 1128 KB Output is correct
41 Correct 36 ms 1356 KB Output is correct
42 Correct 16 ms 1048 KB Output is correct
43 Correct 27 ms 1568 KB Output is correct
44 Correct 27 ms 1576 KB Output is correct
45 Correct 27 ms 1580 KB Output is correct
46 Correct 15 ms 716 KB Output is correct
47 Correct 17 ms 1088 KB Output is correct
48 Correct 31 ms 1640 KB Output is correct
49 Correct 30 ms 1352 KB Output is correct
50 Correct 17 ms 1096 KB Output is correct
51 Correct 3 ms 564 KB Output is correct
52 Correct 44 ms 1816 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 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 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 204 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 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 420 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 3 ms 428 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 2 ms 408 KB Output is correct
35 Correct 2 ms 452 KB Output is correct
36 Correct 2 ms 324 KB Output is correct
37 Correct 9 ms 844 KB Output is correct
38 Correct 8 ms 844 KB Output is correct
39 Correct 37 ms 1196 KB Output is correct
40 Correct 18 ms 1128 KB Output is correct
41 Correct 36 ms 1356 KB Output is correct
42 Correct 16 ms 1048 KB Output is correct
43 Correct 27 ms 1568 KB Output is correct
44 Correct 27 ms 1576 KB Output is correct
45 Correct 27 ms 1580 KB Output is correct
46 Correct 15 ms 716 KB Output is correct
47 Correct 17 ms 1088 KB Output is correct
48 Correct 31 ms 1640 KB Output is correct
49 Correct 30 ms 1352 KB Output is correct
50 Correct 17 ms 1096 KB Output is correct
51 Correct 3 ms 564 KB Output is correct
52 Correct 44 ms 1816 KB Output is correct
53 Correct 28 ms 1420 KB Output is correct
54 Correct 40 ms 1600 KB Output is correct
55 Correct 81 ms 2824 KB Output is correct
56 Correct 32 ms 1572 KB Output is correct
57 Correct 76 ms 2912 KB Output is correct
58 Correct 40 ms 1728 KB Output is correct
59 Correct 65 ms 2140 KB Output is correct
60 Correct 8 ms 716 KB Output is correct
61 Correct 61 ms 2288 KB Output is correct
62 Correct 57 ms 2464 KB Output is correct
63 Correct 66 ms 2692 KB Output is correct
64 Correct 80 ms 2620 KB Output is correct
65 Correct 30 ms 1068 KB Output is correct
66 Correct 30 ms 1192 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 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 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 204 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 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 420 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 3 ms 428 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 2 ms 408 KB Output is correct
35 Correct 2 ms 452 KB Output is correct
36 Correct 2 ms 324 KB Output is correct
37 Correct 9 ms 844 KB Output is correct
38 Correct 8 ms 844 KB Output is correct
39 Correct 37 ms 1196 KB Output is correct
40 Correct 18 ms 1128 KB Output is correct
41 Correct 36 ms 1356 KB Output is correct
42 Correct 16 ms 1048 KB Output is correct
43 Correct 27 ms 1568 KB Output is correct
44 Correct 27 ms 1576 KB Output is correct
45 Correct 27 ms 1580 KB Output is correct
46 Correct 15 ms 716 KB Output is correct
47 Correct 17 ms 1088 KB Output is correct
48 Correct 31 ms 1640 KB Output is correct
49 Correct 30 ms 1352 KB Output is correct
50 Correct 17 ms 1096 KB Output is correct
51 Correct 3 ms 564 KB Output is correct
52 Correct 44 ms 1816 KB Output is correct
53 Correct 28 ms 1420 KB Output is correct
54 Correct 40 ms 1600 KB Output is correct
55 Correct 81 ms 2824 KB Output is correct
56 Correct 32 ms 1572 KB Output is correct
57 Correct 76 ms 2912 KB Output is correct
58 Correct 40 ms 1728 KB Output is correct
59 Correct 65 ms 2140 KB Output is correct
60 Correct 8 ms 716 KB Output is correct
61 Correct 61 ms 2288 KB Output is correct
62 Correct 57 ms 2464 KB Output is correct
63 Correct 66 ms 2692 KB Output is correct
64 Correct 80 ms 2620 KB Output is correct
65 Correct 30 ms 1068 KB Output is correct
66 Correct 30 ms 1192 KB Output is correct
67 Correct 57 ms 2236 KB Output is correct
68 Correct 20 ms 1196 KB Output is correct
69 Correct 204 ms 5136 KB Output is correct
70 Correct 116 ms 3336 KB Output is correct
71 Correct 113 ms 3140 KB Output is correct
72 Correct 112 ms 2176 KB Output is correct
73 Correct 119 ms 2268 KB Output is correct
74 Correct 209 ms 5472 KB Output is correct
75 Correct 168 ms 4304 KB Output is correct
76 Correct 227 ms 5648 KB Output is correct
77 Correct 224 ms 5660 KB Output is correct