#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<=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];
}
long long 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++){
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8000 KB |
Output is correct |
2 |
Correct |
0 ms |
8000 KB |
Output is correct |
3 |
Correct |
0 ms |
8000 KB |
Output is correct |
4 |
Correct |
0 ms |
8000 KB |
Output is correct |
5 |
Correct |
0 ms |
8000 KB |
Output is correct |
6 |
Correct |
0 ms |
8000 KB |
Output is correct |
7 |
Correct |
0 ms |
8000 KB |
Output is correct |
8 |
Correct |
0 ms |
8000 KB |
Output is correct |
9 |
Correct |
3 ms |
8000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8000 KB |
Output is correct |
2 |
Correct |
0 ms |
8000 KB |
Output is correct |
3 |
Correct |
0 ms |
8000 KB |
Output is correct |
4 |
Correct |
0 ms |
8000 KB |
Output is correct |
5 |
Correct |
0 ms |
8000 KB |
Output is correct |
6 |
Correct |
0 ms |
8000 KB |
Output is correct |
7 |
Correct |
0 ms |
8000 KB |
Output is correct |
8 |
Correct |
0 ms |
8000 KB |
Output is correct |
9 |
Correct |
3 ms |
8000 KB |
Output is correct |
10 |
Correct |
0 ms |
8000 KB |
Output is correct |
11 |
Correct |
0 ms |
8000 KB |
Output is correct |
12 |
Correct |
0 ms |
8000 KB |
Output is correct |
13 |
Correct |
0 ms |
8000 KB |
Output is correct |
14 |
Correct |
0 ms |
8000 KB |
Output is correct |
15 |
Correct |
0 ms |
8000 KB |
Output is correct |
16 |
Correct |
0 ms |
8000 KB |
Output is correct |
17 |
Correct |
0 ms |
8000 KB |
Output is correct |
18 |
Correct |
0 ms |
8000 KB |
Output is correct |
19 |
Correct |
0 ms |
8000 KB |
Output is correct |
20 |
Correct |
0 ms |
8000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8000 KB |
Output is correct |
2 |
Correct |
0 ms |
8000 KB |
Output is correct |
3 |
Correct |
0 ms |
8000 KB |
Output is correct |
4 |
Correct |
0 ms |
8000 KB |
Output is correct |
5 |
Correct |
0 ms |
8000 KB |
Output is correct |
6 |
Correct |
0 ms |
8000 KB |
Output is correct |
7 |
Correct |
0 ms |
8000 KB |
Output is correct |
8 |
Correct |
0 ms |
8000 KB |
Output is correct |
9 |
Correct |
3 ms |
8000 KB |
Output is correct |
10 |
Correct |
0 ms |
8000 KB |
Output is correct |
11 |
Correct |
0 ms |
8000 KB |
Output is correct |
12 |
Correct |
0 ms |
8000 KB |
Output is correct |
13 |
Correct |
0 ms |
8000 KB |
Output is correct |
14 |
Correct |
0 ms |
8000 KB |
Output is correct |
15 |
Correct |
0 ms |
8000 KB |
Output is correct |
16 |
Correct |
0 ms |
8000 KB |
Output is correct |
17 |
Correct |
0 ms |
8000 KB |
Output is correct |
18 |
Correct |
0 ms |
8000 KB |
Output is correct |
19 |
Correct |
0 ms |
8000 KB |
Output is correct |
20 |
Correct |
0 ms |
8000 KB |
Output is correct |
21 |
Correct |
1 ms |
8000 KB |
Output is correct |
22 |
Incorrect |
0 ms |
8000 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8000 KB |
Output is correct |
2 |
Correct |
0 ms |
8000 KB |
Output is correct |
3 |
Correct |
0 ms |
8000 KB |
Output is correct |
4 |
Correct |
0 ms |
8000 KB |
Output is correct |
5 |
Correct |
0 ms |
8000 KB |
Output is correct |
6 |
Correct |
0 ms |
8000 KB |
Output is correct |
7 |
Correct |
0 ms |
8000 KB |
Output is correct |
8 |
Correct |
0 ms |
8000 KB |
Output is correct |
9 |
Correct |
3 ms |
8000 KB |
Output is correct |
10 |
Correct |
0 ms |
8000 KB |
Output is correct |
11 |
Correct |
0 ms |
8000 KB |
Output is correct |
12 |
Correct |
0 ms |
8000 KB |
Output is correct |
13 |
Correct |
0 ms |
8000 KB |
Output is correct |
14 |
Correct |
0 ms |
8000 KB |
Output is correct |
15 |
Correct |
0 ms |
8000 KB |
Output is correct |
16 |
Correct |
0 ms |
8000 KB |
Output is correct |
17 |
Correct |
0 ms |
8000 KB |
Output is correct |
18 |
Correct |
0 ms |
8000 KB |
Output is correct |
19 |
Correct |
0 ms |
8000 KB |
Output is correct |
20 |
Correct |
0 ms |
8000 KB |
Output is correct |
21 |
Correct |
1 ms |
8000 KB |
Output is correct |
22 |
Incorrect |
0 ms |
8000 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8000 KB |
Output is correct |
2 |
Correct |
0 ms |
8000 KB |
Output is correct |
3 |
Correct |
0 ms |
8000 KB |
Output is correct |
4 |
Correct |
0 ms |
8000 KB |
Output is correct |
5 |
Correct |
0 ms |
8000 KB |
Output is correct |
6 |
Correct |
0 ms |
8000 KB |
Output is correct |
7 |
Correct |
0 ms |
8000 KB |
Output is correct |
8 |
Correct |
0 ms |
8000 KB |
Output is correct |
9 |
Correct |
3 ms |
8000 KB |
Output is correct |
10 |
Correct |
0 ms |
8000 KB |
Output is correct |
11 |
Correct |
0 ms |
8000 KB |
Output is correct |
12 |
Correct |
0 ms |
8000 KB |
Output is correct |
13 |
Correct |
0 ms |
8000 KB |
Output is correct |
14 |
Correct |
0 ms |
8000 KB |
Output is correct |
15 |
Correct |
0 ms |
8000 KB |
Output is correct |
16 |
Correct |
0 ms |
8000 KB |
Output is correct |
17 |
Correct |
0 ms |
8000 KB |
Output is correct |
18 |
Correct |
0 ms |
8000 KB |
Output is correct |
19 |
Correct |
0 ms |
8000 KB |
Output is correct |
20 |
Correct |
0 ms |
8000 KB |
Output is correct |
21 |
Correct |
1 ms |
8000 KB |
Output is correct |
22 |
Incorrect |
0 ms |
8000 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8000 KB |
Output is correct |
2 |
Correct |
0 ms |
8000 KB |
Output is correct |
3 |
Correct |
0 ms |
8000 KB |
Output is correct |
4 |
Correct |
0 ms |
8000 KB |
Output is correct |
5 |
Correct |
0 ms |
8000 KB |
Output is correct |
6 |
Correct |
0 ms |
8000 KB |
Output is correct |
7 |
Correct |
0 ms |
8000 KB |
Output is correct |
8 |
Correct |
0 ms |
8000 KB |
Output is correct |
9 |
Correct |
3 ms |
8000 KB |
Output is correct |
10 |
Correct |
0 ms |
8000 KB |
Output is correct |
11 |
Correct |
0 ms |
8000 KB |
Output is correct |
12 |
Correct |
0 ms |
8000 KB |
Output is correct |
13 |
Correct |
0 ms |
8000 KB |
Output is correct |
14 |
Correct |
0 ms |
8000 KB |
Output is correct |
15 |
Correct |
0 ms |
8000 KB |
Output is correct |
16 |
Correct |
0 ms |
8000 KB |
Output is correct |
17 |
Correct |
0 ms |
8000 KB |
Output is correct |
18 |
Correct |
0 ms |
8000 KB |
Output is correct |
19 |
Correct |
0 ms |
8000 KB |
Output is correct |
20 |
Correct |
0 ms |
8000 KB |
Output is correct |
21 |
Correct |
1 ms |
8000 KB |
Output is correct |
22 |
Incorrect |
0 ms |
8000 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |