Submission #670124

#TimeUsernameProblemLanguageResultExecution timeMemory
670124mychecksedadBootfall (IZhO17_bootfall)C++17
0 / 100
1 ms340 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define pb push_back const int N = 510, M = 500; int n, a[N], S = 0; bitset<N*N/2> dp[N]; void solve(){ cin >> n; bool ok = 1; for(int i = 1; i <= n; ++i){ cin >> a[i]; S += a[i]; if(a[i] % 2 != a[1] % 2){ ok = 0; } } if(!ok || (n % 2 == 1 && a[1] % 2 == 1)){ cout << 0; return; } for(int i = 0; i <= n; ++i){ dp[i][0] = 1; for(int l = 1; l <= n; ++l){ if(i == l) continue; for(int j = M - a[l]; j >= 0; --j){ dp[i][j + a[l]] = dp[i][j + a[l]] | (dp[i][j] << a[l]); } } } vector<int> possible; for(int x = 2 - (a[1] % 2); x <= M * M; x += 2){ ok = 1; a[0] = x; for(int i = 0; i <= n; ++i){ int req = (S + x - a[i]) >> 1; if(req >= M * M || !dp[i][req]){ ok = 0; break; } } if(ok){ possible.pb(x); } } cout << possible.size() << '\n'; for(int p: possible) cout << p << ' '; } int main(){ cin.tie(0); ios::sync_with_stdio(0); solve(); 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...