제출 #1153737

#제출 시각아이디문제언어결과실행 시간메모리
1153737GabitussBootfall (IZhO17_bootfall)C++20
0 / 100
5 ms328 KiB
#include <bits/stdc++.h> using namespace std; //@formatter:off using ll = long long; using ld = double; template<typename T> istream &operator>>(istream &is, vector<T> &a); template<typename T> ostream &operator<<(ostream &os, vector<T> &a); //@formatter:on const int Vmax = 400; const int mod = 1e9 + 7; const int N = 20 * 20 + Vmax + 50; int add(int a, int b) { if (a + b >= mod) return a + b - mod; return a + b; } int sub(int a, int b) { if (a - b < 0) return a - b + mod; return a - b; } signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else ios_base::sync_with_stdio(false); cin.tie(0); #endif int n; cin >> n; vector<int> a(n); cin >> a; vector<int> ans; for (int V = 1; V <= Vmax; ++V) { vector<int> b = a; b.push_back(V); vector<int> dp(N); dp[0] = 1; ll sum = std::accumulate(b.begin(), b.end(), 0ll); for (int i = 0; i <= n; ++i) { for (int j = N - 1; j >= b[i]; --j) { if (j - b[i] >= 0) { dp[j] = add(dp[j - b[i]], dp[j]); } } } bool good = true; for (int i = 0; i <= n; ++i) { if ((sum - b[i]) % 2 == 1) { good = false; continue; } for (int j = b[i]; j < N; ++j) { if (j - b[i] >= 0) { dp[j] = sub(dp[j], dp[j - b[i]]); } } good &= dp[(sum - b[i]) / 2] != 0; for (int j = N - 1; j >= b[i]; --j) { if (j - b[i] >= 0) { dp[j] = add(dp[j - b[i]], dp[j]); } } } if (good) { ans.push_back(V); } } cout << ans.size() << "\n"; cout << ans; } // region POZOR template<typename T> ostream &operator<<(ostream &os, vector<T> &a) { for (int i = 0; i < a.size(); i++) os << a[i] << " \n"[i == a.size() - 1]; return os; } template<typename T> istream &operator>>(istream &is, vector<T> &a) { for (auto &i: a) is >> i; return is; } // endregion
#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...