Submission #39856

# Submission time Handle Problem Language Result Execution time Memory
39856 2018-01-21T21:25:08 Z igzi Bootfall (IZhO17_bootfall) C++14
13 / 100
50 ms 8000 KB
#include <bits/stdc++.h>
#define maxN 505
#define maxA 505

using namespace std;

long long n,i,j,s=0,a[maxN],b[maxN*maxA],c[maxN*maxA],tmp[maxN*maxA];
vector <long long> ans;

int main()
{
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    for(i=0;i<=250000;i++){
        b[i]=0;
        c[i]=0;
    }
    b[0]=1;
    for(i=0;i<n;i++){
        for(j=250000;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<=250000+a[i];j++){
        tmp[j]=0;
    }
    for(j=0;j<=250000;j++){
        tmp[j]+=b[j];
        tmp[j+a[i]]-=tmp[j];
    }
    long long x;
    for(x=0;x<=250000;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<=250000;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 4 ms 8000 KB Output is correct
2 Correct 3 ms 8000 KB Output is correct
3 Correct 0 ms 8000 KB Output is correct
4 Correct 6 ms 8000 KB Output is correct
5 Correct 8 ms 8000 KB Output is correct
6 Correct 9 ms 8000 KB Output is correct
7 Correct 4 ms 8000 KB Output is correct
8 Correct 6 ms 8000 KB Output is correct
9 Correct 7 ms 8000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8000 KB Output is correct
2 Correct 3 ms 8000 KB Output is correct
3 Correct 0 ms 8000 KB Output is correct
4 Correct 6 ms 8000 KB Output is correct
5 Correct 8 ms 8000 KB Output is correct
6 Correct 9 ms 8000 KB Output is correct
7 Correct 4 ms 8000 KB Output is correct
8 Correct 6 ms 8000 KB Output is correct
9 Correct 7 ms 8000 KB Output is correct
10 Correct 21 ms 8000 KB Output is correct
11 Correct 23 ms 8000 KB Output is correct
12 Correct 23 ms 8000 KB Output is correct
13 Correct 21 ms 8000 KB Output is correct
14 Correct 20 ms 8000 KB Output is correct
15 Correct 27 ms 8000 KB Output is correct
16 Correct 27 ms 8000 KB Output is correct
17 Correct 18 ms 8000 KB Output is correct
18 Correct 22 ms 8000 KB Output is correct
19 Correct 16 ms 8000 KB Output is correct
20 Correct 27 ms 8000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8000 KB Output is correct
2 Correct 3 ms 8000 KB Output is correct
3 Correct 0 ms 8000 KB Output is correct
4 Correct 6 ms 8000 KB Output is correct
5 Correct 8 ms 8000 KB Output is correct
6 Correct 9 ms 8000 KB Output is correct
7 Correct 4 ms 8000 KB Output is correct
8 Correct 6 ms 8000 KB Output is correct
9 Correct 7 ms 8000 KB Output is correct
10 Correct 21 ms 8000 KB Output is correct
11 Correct 23 ms 8000 KB Output is correct
12 Correct 23 ms 8000 KB Output is correct
13 Correct 21 ms 8000 KB Output is correct
14 Correct 20 ms 8000 KB Output is correct
15 Correct 27 ms 8000 KB Output is correct
16 Correct 27 ms 8000 KB Output is correct
17 Correct 18 ms 8000 KB Output is correct
18 Correct 22 ms 8000 KB Output is correct
19 Correct 16 ms 8000 KB Output is correct
20 Correct 27 ms 8000 KB Output is correct
21 Correct 50 ms 8000 KB Output is correct
22 Incorrect 46 ms 8000 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8000 KB Output is correct
2 Correct 3 ms 8000 KB Output is correct
3 Correct 0 ms 8000 KB Output is correct
4 Correct 6 ms 8000 KB Output is correct
5 Correct 8 ms 8000 KB Output is correct
6 Correct 9 ms 8000 KB Output is correct
7 Correct 4 ms 8000 KB Output is correct
8 Correct 6 ms 8000 KB Output is correct
9 Correct 7 ms 8000 KB Output is correct
10 Correct 21 ms 8000 KB Output is correct
11 Correct 23 ms 8000 KB Output is correct
12 Correct 23 ms 8000 KB Output is correct
13 Correct 21 ms 8000 KB Output is correct
14 Correct 20 ms 8000 KB Output is correct
15 Correct 27 ms 8000 KB Output is correct
16 Correct 27 ms 8000 KB Output is correct
17 Correct 18 ms 8000 KB Output is correct
18 Correct 22 ms 8000 KB Output is correct
19 Correct 16 ms 8000 KB Output is correct
20 Correct 27 ms 8000 KB Output is correct
21 Correct 50 ms 8000 KB Output is correct
22 Incorrect 46 ms 8000 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8000 KB Output is correct
2 Correct 3 ms 8000 KB Output is correct
3 Correct 0 ms 8000 KB Output is correct
4 Correct 6 ms 8000 KB Output is correct
5 Correct 8 ms 8000 KB Output is correct
6 Correct 9 ms 8000 KB Output is correct
7 Correct 4 ms 8000 KB Output is correct
8 Correct 6 ms 8000 KB Output is correct
9 Correct 7 ms 8000 KB Output is correct
10 Correct 21 ms 8000 KB Output is correct
11 Correct 23 ms 8000 KB Output is correct
12 Correct 23 ms 8000 KB Output is correct
13 Correct 21 ms 8000 KB Output is correct
14 Correct 20 ms 8000 KB Output is correct
15 Correct 27 ms 8000 KB Output is correct
16 Correct 27 ms 8000 KB Output is correct
17 Correct 18 ms 8000 KB Output is correct
18 Correct 22 ms 8000 KB Output is correct
19 Correct 16 ms 8000 KB Output is correct
20 Correct 27 ms 8000 KB Output is correct
21 Correct 50 ms 8000 KB Output is correct
22 Incorrect 46 ms 8000 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8000 KB Output is correct
2 Correct 3 ms 8000 KB Output is correct
3 Correct 0 ms 8000 KB Output is correct
4 Correct 6 ms 8000 KB Output is correct
5 Correct 8 ms 8000 KB Output is correct
6 Correct 9 ms 8000 KB Output is correct
7 Correct 4 ms 8000 KB Output is correct
8 Correct 6 ms 8000 KB Output is correct
9 Correct 7 ms 8000 KB Output is correct
10 Correct 21 ms 8000 KB Output is correct
11 Correct 23 ms 8000 KB Output is correct
12 Correct 23 ms 8000 KB Output is correct
13 Correct 21 ms 8000 KB Output is correct
14 Correct 20 ms 8000 KB Output is correct
15 Correct 27 ms 8000 KB Output is correct
16 Correct 27 ms 8000 KB Output is correct
17 Correct 18 ms 8000 KB Output is correct
18 Correct 22 ms 8000 KB Output is correct
19 Correct 16 ms 8000 KB Output is correct
20 Correct 27 ms 8000 KB Output is correct
21 Correct 50 ms 8000 KB Output is correct
22 Incorrect 46 ms 8000 KB Output isn't correct
23 Halted 0 ms 0 KB -