# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
689931 | YENGOYAN | Bootfall (IZhO17_bootfall) | C++17 | 593 ms | 4532 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.
/*
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
\\ //
// 271828___182845__904523__53602__ \\
\\ 87___47____13______52____66__24_ //
// 97___75____72______47____09___36 \\
\\ 999595_____74______96____69___67 //
// 62___77____24______07____66__30_ \\
\\ 35___35____47______59____45713__ //
// \\
\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//
*/
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <algorithm>
#include <random>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <tuple>
#include <bitset>
#include <chrono>
#include <ctime>
#include <fstream>
#include <stack>
#include <cstdio>
using namespace std;
using ll = long long;
const int N = 3e5 + 5;
const ll mod = 1e9 + 7, inf = 1e18;
void solve() {
int n; cin >> n;
vector<int> v(n);
for (int i = 0; i < n; ++i) cin >> v[i];
vector<ll> dp(250005);
dp[0] = 1;
ll sm = 0;
for (int i = 0; i < n; ++i) {
sm += v[i];
for (int j = 250000 - v[i]; j >= 0; --j) {
dp[j + v[i]] += dp[j];
}
}
if (sm % 2 || !dp[sm / 2]) {
cout << "0\n";
return;
}
//return;
vector<int> cnts(250005);
vector<int> res;
for (int i = 0; i < n; ++i) {
for (int j = 0; j <= 250000; ++j) {
if (dp[j] && j * 2 >= sm - v[i]) {
++cnts[2 * j - (sm - v[i])];
if (cnts[2 * j - (sm - v[i])] == n) res.push_back(2 * j - (sm - v[i]));
}
if(j + v[i] <= 250000) dp[j + v[i]] -= dp[j];
}
for (int j = 250000 - v[i]; j >= 0; --j) dp[j + v[i]] += dp[j];
}
cout << res.size() << "\n";
for (int i = 0; i < res.size(); ++i) cout << res[i] << " \n"[i + 1 == res.size()];
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
//int t; cin >> t;
//while (t--)
solve();
}
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... |