Submission #1124238

#TimeUsernameProblemLanguageResultExecution timeMemory
1124238davitmargBootfall (IZhO17_bootfall)C++17
0 / 100
0 ms320 KiB
/* DEATH-MATCH Davit-Marg */ #include <iostream> #include <algorithm> #include <cmath> #include <cassert> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <iterator> #include <ctype.h> #include <stdlib.h> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back using namespace std; LL n,a[5000006],cant[5000006]; LL sum,sm; vector<LL> ans; LL dp[5000006]; void add(LL k) { sum += k; for (LL j = sum; j >= 0; j--) dp[j + k] += dp[j]; } void rem(LL k) { for (LL i = 0; i <= sum; i++) dp[i + k] -= dp[i]; sum -= k; } int main() { cin >> n; for (LL i = 0; i < n; i++) { cin >> a[i]; sm += a[i]; } dp[0] = 1ll; for (LL i = 0; i < n; i++) add(a[i]); if (sm % 2==1 || dp[sm / 2] == 0) { cout << 0 << endl; return 0; } for (LL i = 0; i < n; i++) { for (LL j = 0; j <= sm; j++) { //assert(dp[(sum + j) / 2]<0); if ((sum + j) % 2 == 1 || dp[(sum + j) / 2 - j] == 0) cant[j] = 1; } } for (LL j = 0; j <= sm; j++) if (!cant[j]) ans.PB(j); cout << ans.size() << endl; for (LL i = 0; i < ans.size(); i++) cout << ans[i] << " "; cout << endl; return 0; }
#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...