Submission #343368

#TimeUsernameProblemLanguageResultExecution timeMemory
343368spike1236Bootfall (IZhO17_bootfall)C++14
100 / 100
338 ms4460 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define f first #define s second #define ll long long #define ld long double #define all(_v) _v.begin(), _v.end() #define sz(_v) (int)_v.size() #define pii pair <int, int> #define pll pair <ll, ll> #define veci vector <int> #define vecll vector <ll> const int dx[4] = {1, -1, 0, 0}; const int dy[4] = {0, 0, -1, 1}; const double PI = 3.1415926535897932384626433832795; const double eps = 1e-9; const int MOD1 = 1e9 + 7; const int MOD2 = 998244353; const int MX = 250010; int n; int a[510]; int used[MX]; ll dp[MX]; int sum; void add(int x) { for(int i = sum; i >= 0; --i) dp[i + x] += dp[i]; sum += x; } void del(int x) { sum -= x; for(int i = 0; i <= sum; ++i) dp[i + x] -= dp[i]; } void solve() { cin >> n; dp[0] = 1; for(int i = 1; i <= n; ++i) cin >> a[i], add(a[i]); if(sum & 1 || !dp[sum / 2]) { cout << 0; return; } veci ans; for(int i = 1; i <= n; ++i) { del(a[i]); for(int j = 1; j < MX; ++j) if((sum + j) & 1 || !dp[(sum + j) / 2]) used[j] = 1; add(a[i]); } for(int i = 1; i < MX; ++i) if(!used[i]) ans.pb(i); cout << sz(ans) << '\n'; for(auto it : ans) cout << it << ' '; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T = 1; ///cin >> T; while(T--) solve(), cout << '\n'; 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...