제출 #93831

#제출 시각아이디문제언어결과실행 시간메모리
93831dalgerokBootfall (IZhO17_bootfall)C++14
44 / 100
172 ms2020 KiB
#include<bits/stdc++.h> using namespace std; const int N = 505, M = 1e7 + 5, MOD = 1e9 + 9; int n, a[N], sum, ssum; bool used[M]; long long dp[M]; inline void Add(int val){ sum += val; for(int i = sum; i >= 0; i--){ dp[i + val] += dp[i]; if(dp[i + val] >= MOD){ dp[i + val] -= MOD; } } } inline void Del(int val){ for(int i = 0; i <= sum; i++){ dp[i + val] -= dp[i]; if(dp[i + val] < 0){ dp[i + val] += MOD; } } sum -= val; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; dp[0] = 1; for(int i = 1; i <= n; i++){ cin >> a[i]; ssum += a[i]; Add(a[i]); } for(int i = 1; i <= ssum; i++){ used[i] = true; } if(ssum % 2 || dp[ssum / 2] == 0){ return cout << 0, 0; } for(int i = 1; i <= n; i++){ Del(a[i]); for(int j = 1; j <= ssum; j++){ if((sum + j) % 2 || dp[(sum + j) / 2] == 0){ used[j] = false; } } Add(a[i]); } vector < int > ans; for(int i = 1; i <= ssum; i++){ if(used[i]){ ans.push_back(i); } } cout << (int)ans.size() << "\n"; for(auto it : ans){ cout << it << " "; } }
#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...