| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1333210 | aaaaaaaa | Bootfall (IZhO17_bootfall) | C++20 | 234 ms | 5804 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = 500 * 500 + 10;
int a[505], dp[mxN], freq[mxN];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, sum = 0;
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> a[i];
sum += a[i];
}
dp[0] = 1;
for(int i = 1; i <= n; ++i){
for(int j = sum; j >= a[i]; --j){
dp[j] += dp[j - a[i]];
}
}
if (sum & 1 || !dp[sum / 2]) cout << "0\n";
else {
for(int i = 1; i <= n; ++i){
for(int j = a[i]; j <= sum; ++j){
dp[j] -= dp[j - a[i]];
}
for(int j = 0; j * 2 <= (sum - a[i]); ++j){
if(!dp[j]) continue;
freq[sum - a[i] - j * 2] += 1;
}
for(int j = sum; j >= a[i]; --j){
dp[j] += dp[j - a[i]];
}
}
vector<int> ans;
for(int i = 1; i < mxN; ++i){
if(freq[i] == n) ans.push_back(i);
}
cout << (int) ans.size() << "\n";
for(auto it : ans){
cout << it << " ";
}
}
return 0;
}
| # | 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... | ||||
