//Bismillahir-Rahmanir-Rahim
# include <bits/stdc++.h>
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
# define deb(x) cerr << #x << " = " << x << endl;
# define pll pair <ll, ll>
# define pii pair <int, int>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll maxn = 5e2 + 3;
const ll inf = 2e18 + 0;
const ll mod = 1e9 + 7;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bitset <maxn * maxn * 2> dp[maxn], bs;
int sum[maxn];
void ma1n (/* SABR */) {
int n;
cin >> n;
int a[n + 3];
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
for (int i = 1; i <= n; ++i) {
dp[i][0] = 1;
for (int j = 1; j <= n; ++j) {
if (j != i) {
dp[i] |= (dp[i] << a[j]);
sum[i] += a[j];
}
}
}
vector <int> ans;
for (int x = 1; x <= 25000; ++x) {
bool ok = 1;
for (int i = 1; i <= n; ++i) {
if ((sum[i] + x) & 1) {
ok = 0;
break;
}
bs = dp[i] | (dp[i] << x);
if (bs[(sum[i] + x) / 2] == 0) {
ok = 0;
break;
}
}
if (ok) {
ans.pb(x);
}
}
cout << sz(ans) << nl;
for (int x : ans) cout << x << ' ';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
int ttt = 1;
// cin >> ttt;
for (int test = 1; test <= ttt; ++test) {
// cout << "Case " << test << ":" << '\n';
ma1n();
}
return 0;
}
// 998batrr | BbIWEJI 3A TObOU!!!
// tourist | BbIWEJI 3A TObOU!!!
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
189 ms |
844 KB |
Output is correct |
2 |
Correct |
177 ms |
876 KB |
Output is correct |
3 |
Incorrect |
176 ms |
696 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
189 ms |
844 KB |
Output is correct |
2 |
Correct |
177 ms |
876 KB |
Output is correct |
3 |
Incorrect |
176 ms |
696 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
189 ms |
844 KB |
Output is correct |
2 |
Correct |
177 ms |
876 KB |
Output is correct |
3 |
Incorrect |
176 ms |
696 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
189 ms |
844 KB |
Output is correct |
2 |
Correct |
177 ms |
876 KB |
Output is correct |
3 |
Incorrect |
176 ms |
696 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
189 ms |
844 KB |
Output is correct |
2 |
Correct |
177 ms |
876 KB |
Output is correct |
3 |
Incorrect |
176 ms |
696 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
189 ms |
844 KB |
Output is correct |
2 |
Correct |
177 ms |
876 KB |
Output is correct |
3 |
Incorrect |
176 ms |
696 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |