Submission #344922

#TimeUsernameProblemLanguageResultExecution timeMemory
344922_aniBootfall (IZhO17_bootfall)C++17
0 / 100
1 ms492 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int N = 100; int dp[N + 1][N + 1][N * N + 1]; vector<int> a; int b[N]; vector<int> ans; int sum; int main() { int n; cin >> n; a.resize(n); for (int i = 0; i < n; i++) { cin >> a[i]; a[i] = b[i]; sum += a[i]; } for (int i = 0; i < n; i++) { int jnj = b[i]; a.erase(find(a.begin(), a.end(), jnj)); for (int i = 0; i < n; i++) dp[jnj][i][a[i]] = dp[jnj][i][0] = 1; for (int i = 0; i < n - 1; i++) for (int j = 1; j <= N * N; j++) if (j >= a[i] && i >= 1) dp[jnj][i][j] = dp[jnj][i - 1][j - a[i]]; a.push_back(jnj); } for (int i = 1; i <= N*N; i++) { int cnt = 0; for (int j = 0; j < n; j++) { if ((sum - b[j] + i) % 2 == 0) { int tmp = (sum - b[j] + i) / 2; for (int k = 0; k < n; k++) if (dp[a[j]][k][tmp]) { cnt++; break; } } } if (cnt == n)ans.push_back(i); } cout << ans.size() << '\n'; for (int v : ans) cout << v << ' '; 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...