Submission #314972

#TimeUsernameProblemLanguageResultExecution timeMemory
314972shrek12357Bootfall (IZhO17_bootfall)C++14
0 / 100
3 ms384 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> #include <stack> #include <bitset> using namespace std; #define ll long long //cin.tie(0);ios_base::sync_with_stdio(0); int main() { int n; cin >> n; vector<int> nums; bitset<250001> ans; ans.flip(); int sum = 0; for (int i = 0; i < n; i++) { int temp; cin >> temp; sum += temp; nums.push_back(temp); } for (int i = 0; i < n; i++) { bitset<250001> dp; dp[0] = 1; for (int j = 0; j < n; j++) { if (i == j) { continue; } dp |= (dp << nums[j]); } bitset<250001> check; int curSum = sum - nums[i]; for (int j = 1; j < 250001; j++) { if (dp[j] == 1) { int l = j; int r = curSum - j; if (r == 0) { continue; } check[abs(r - l)] = 1; } } ans &= check; } ans[0] = 0; cout << ans.count() << endl; for (int i = 1; i < 250000; i++) { if (ans[i] == 1) { cout << i << endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...