Submission #566234

#TimeUsernameProblemLanguageResultExecution timeMemory
566234RealSnakeBootfall (IZhO17_bootfall)C++14
28 / 100
1089 ms25608 KiB
#include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define mod 1000000007 ofstream fout(".out"); ifstream fin(".in"); int b[501][250001]; signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int arr[n]; int sum = 0; for(int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } b[n][0] = 1; for(int i = 0; i < n; i++) { for(int j = sum; j >= arr[i]; j--) b[n][j] |= b[n][j - arr[i]]; } if(sum % 2 || !b[n][sum / 2]) { cout << 0; return 0; } for(int k = 0; k < n; k++) { b[k][0] = 1; sum -= arr[k]; for(int i = 0; i < n; i++) { if(i == k) continue; for(int j = sum; j >= arr[i]; j--) b[k][j] |= b[k][j - arr[i]]; } sum += arr[k]; } vector<int> ans; for(int i = 1; i <= sum; i++) { bool bb = 1; for(int j = 0; j < n; j++) { int x = sum - arr[j] + i; if(i % 2 != arr[j] % 2 || x < 0 || !b[j][x / 2]) { bb = 0; break; } } if(bb) ans.push_back(i); } cout << ans.size() << "\n"; for(int i : ans) cout << i << " "; 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...