Submission #39853

# Submission time Handle Problem Language Result Execution time Memory
39853 2018-01-21T21:14:59 Z igzi Bootfall (IZhO17_bootfall) C++14
13 / 100
1 ms 5008 KB
#include <bits/stdc++.h>
#define maxN 505
#define maxA 505
 
using namespace std;
 
int n,i,j,s=0,a[maxN],b[maxN*maxA],c[maxN*maxA],tmp[maxN*maxA];
vector <int> v,ans;
 
int main()
{
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    for(i=0;i<=s;i++){
        b[i]=0;
        c[i]=0;
    }
    b[0]=1;
    for(i=0;i<n;i++){
        for(j=s;j>=0;j--){
            if(b[j]!=0) b[a[i]+j]+=b[j];
        }
    }
    if(s%2 || b[s/2]==0) cout<<0<<endl;
    else{
        for(i=0;i<n;i++){
            for(j=0;j<=s+a[i];j++){
        tmp[j]=0;
    }
    for(j=0;j<=s;j++){
        tmp[j]+=b[j];
        tmp[j+a[i]]-=tmp[j];
    }
    int x;
    for(x=0;x<=s;x++){
    if(s-x-a[i]<0) break;
    if((s+x-a[i])%2==0 && tmp[(s-x-a[i])/2]>0) c[x]++;
        }
        }
        for(i=0;i<=s;i++){
            if(c[i]==n) ans.push_back(i);
        }
        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
    }
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:47:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0;i<ans.size();i++){
                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5008 KB Output is correct
2 Correct 0 ms 5008 KB Output is correct
3 Correct 0 ms 5008 KB Output is correct
4 Correct 0 ms 5008 KB Output is correct
5 Correct 0 ms 5008 KB Output is correct
6 Correct 0 ms 5008 KB Output is correct
7 Correct 0 ms 5008 KB Output is correct
8 Correct 0 ms 5008 KB Output is correct
9 Correct 0 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5008 KB Output is correct
2 Correct 0 ms 5008 KB Output is correct
3 Correct 0 ms 5008 KB Output is correct
4 Correct 0 ms 5008 KB Output is correct
5 Correct 0 ms 5008 KB Output is correct
6 Correct 0 ms 5008 KB Output is correct
7 Correct 0 ms 5008 KB Output is correct
8 Correct 0 ms 5008 KB Output is correct
9 Correct 0 ms 5008 KB Output is correct
10 Correct 0 ms 5008 KB Output is correct
11 Correct 0 ms 5008 KB Output is correct
12 Correct 0 ms 5008 KB Output is correct
13 Correct 0 ms 5008 KB Output is correct
14 Correct 0 ms 5008 KB Output is correct
15 Correct 0 ms 5008 KB Output is correct
16 Correct 0 ms 5008 KB Output is correct
17 Correct 0 ms 5008 KB Output is correct
18 Correct 0 ms 5008 KB Output is correct
19 Correct 0 ms 5008 KB Output is correct
20 Correct 0 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5008 KB Output is correct
2 Correct 0 ms 5008 KB Output is correct
3 Correct 0 ms 5008 KB Output is correct
4 Correct 0 ms 5008 KB Output is correct
5 Correct 0 ms 5008 KB Output is correct
6 Correct 0 ms 5008 KB Output is correct
7 Correct 0 ms 5008 KB Output is correct
8 Correct 0 ms 5008 KB Output is correct
9 Correct 0 ms 5008 KB Output is correct
10 Correct 0 ms 5008 KB Output is correct
11 Correct 0 ms 5008 KB Output is correct
12 Correct 0 ms 5008 KB Output is correct
13 Correct 0 ms 5008 KB Output is correct
14 Correct 0 ms 5008 KB Output is correct
15 Correct 0 ms 5008 KB Output is correct
16 Correct 0 ms 5008 KB Output is correct
17 Correct 0 ms 5008 KB Output is correct
18 Correct 0 ms 5008 KB Output is correct
19 Correct 0 ms 5008 KB Output is correct
20 Correct 0 ms 5008 KB Output is correct
21 Incorrect 1 ms 5008 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5008 KB Output is correct
2 Correct 0 ms 5008 KB Output is correct
3 Correct 0 ms 5008 KB Output is correct
4 Correct 0 ms 5008 KB Output is correct
5 Correct 0 ms 5008 KB Output is correct
6 Correct 0 ms 5008 KB Output is correct
7 Correct 0 ms 5008 KB Output is correct
8 Correct 0 ms 5008 KB Output is correct
9 Correct 0 ms 5008 KB Output is correct
10 Correct 0 ms 5008 KB Output is correct
11 Correct 0 ms 5008 KB Output is correct
12 Correct 0 ms 5008 KB Output is correct
13 Correct 0 ms 5008 KB Output is correct
14 Correct 0 ms 5008 KB Output is correct
15 Correct 0 ms 5008 KB Output is correct
16 Correct 0 ms 5008 KB Output is correct
17 Correct 0 ms 5008 KB Output is correct
18 Correct 0 ms 5008 KB Output is correct
19 Correct 0 ms 5008 KB Output is correct
20 Correct 0 ms 5008 KB Output is correct
21 Incorrect 1 ms 5008 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5008 KB Output is correct
2 Correct 0 ms 5008 KB Output is correct
3 Correct 0 ms 5008 KB Output is correct
4 Correct 0 ms 5008 KB Output is correct
5 Correct 0 ms 5008 KB Output is correct
6 Correct 0 ms 5008 KB Output is correct
7 Correct 0 ms 5008 KB Output is correct
8 Correct 0 ms 5008 KB Output is correct
9 Correct 0 ms 5008 KB Output is correct
10 Correct 0 ms 5008 KB Output is correct
11 Correct 0 ms 5008 KB Output is correct
12 Correct 0 ms 5008 KB Output is correct
13 Correct 0 ms 5008 KB Output is correct
14 Correct 0 ms 5008 KB Output is correct
15 Correct 0 ms 5008 KB Output is correct
16 Correct 0 ms 5008 KB Output is correct
17 Correct 0 ms 5008 KB Output is correct
18 Correct 0 ms 5008 KB Output is correct
19 Correct 0 ms 5008 KB Output is correct
20 Correct 0 ms 5008 KB Output is correct
21 Incorrect 1 ms 5008 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5008 KB Output is correct
2 Correct 0 ms 5008 KB Output is correct
3 Correct 0 ms 5008 KB Output is correct
4 Correct 0 ms 5008 KB Output is correct
5 Correct 0 ms 5008 KB Output is correct
6 Correct 0 ms 5008 KB Output is correct
7 Correct 0 ms 5008 KB Output is correct
8 Correct 0 ms 5008 KB Output is correct
9 Correct 0 ms 5008 KB Output is correct
10 Correct 0 ms 5008 KB Output is correct
11 Correct 0 ms 5008 KB Output is correct
12 Correct 0 ms 5008 KB Output is correct
13 Correct 0 ms 5008 KB Output is correct
14 Correct 0 ms 5008 KB Output is correct
15 Correct 0 ms 5008 KB Output is correct
16 Correct 0 ms 5008 KB Output is correct
17 Correct 0 ms 5008 KB Output is correct
18 Correct 0 ms 5008 KB Output is correct
19 Correct 0 ms 5008 KB Output is correct
20 Correct 0 ms 5008 KB Output is correct
21 Incorrect 1 ms 5008 KB Output isn't correct
22 Halted 0 ms 0 KB -