# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36181 | ToMoClone | Bootfall (IZhO17_bootfall) | C++14 | 679 ms | 6976 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.
/*input
4
1 3 1 5
*/
#include <stdio.h>
#include <vector>
using namespace std;
const int N = 501;
int check[N * N], cnt[250001], num[1000001], a[N], n, sum, ans;
int main(){
scanf("%d", &n);
check[0] = 1;
for(int i = 1; i <= n; ++i){
scanf("%d", &a[i]), sum += a[i];
for(int j = sum; j >= a[i]; --j)
check[j] += check[j - a[i]];
}
if((sum & 1) || check[sum >> 1] == 0) return puts("0"), 0;
for(int i = 1; i <= n; ++i){
for(int j = 0; j <= sum - a[i]; ++j)
check[j + a[i]] -= check[j];
for(int j = 1; j <= sum; ++j){
int Sum = sum + j - a[i];
if((Sum & 1) || ((Sum >> 1) < j)) continue;
if(check[Sum >> 1] != 0 && check[(Sum >> 1) - j] != 0) ++num[j];
ans += (num[j] == n);
}
for(int j = sum; j >= a[i]; --j)
check[j] += check[j - a[i]];
}
printf("%d\n", ans);
if(ans != 0){
for(int i = 1; i <= sum; ++i)
if(num[i] == n) printf("%d ", i);
puts("");
}
}
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... |