# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95501 | choikiwon | Bootfall (IZhO17_bootfall) | C++17 | 1072 ms | 988 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.
#include<bits/stdc++.h>
using namespace std;
const int MN = 502;
int N;
int A[MN];
bitset<MN * MN> dp;
int cnt[MN * MN];
int main() {
scanf("%d", &N);
int sum = 0;
for(int i = 0; i < N; i++) {
scanf("%d", &A[i]);
sum += A[i];
}
if(sum % 2) {
printf("0");
return 0;
}
dp[0] = 1;
for(int i = 0; i < N; i++) {
dp |= (dp << A[i]);
}
if(!dp[sum / 2]) {
printf("0");
return 0;
}
for(int x = 0; x < N; x++) {
dp.reset();
dp[0] = 1;
for(int i = 0; i < N; i++) {
if(i == x) continue;
dp |= (dp << A[i]);
}
for(int i = 0; i < MN * MN; i++) {
if(dp[i] && 2 * i + A[x] - sum >= 0) {
cnt[ 2 * i + A[x] - sum ]++;
}
}
}
int ans = 0;
for(int i = 0; i < MN * MN; i++) {
if(cnt[i] == N) {
ans++;
}
}
printf("%d\n", ans);
for(int i = 0; i < MN * MN; i++) {
if(cnt[i] == N) {
printf("%d ", i);
}
}
}
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... |