| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1333206 | aaaaaaaa | Bootfall (IZhO17_bootfall) | C++20 | 1 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = 72905;
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]];
}
int rem = sum - a[i];
for(int j = 0; j <= sum; ++j){
if(!dp[j]) continue;
if(j * 2 > rem) break;
if((rem - j * 2) < mxN) {
freq[rem - j * 2] += 1;
}
}
for(int j = sum; j >= a[i]; --j){
dp[j] += dp[j - a[i]];
}
}
}
vector<int> ans;
for(int i = 0; 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... | ||||
