# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97608 | Kalam | Bootfall (IZhO17_bootfall) | C++11 | 642 ms | 2876 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// 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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |