#include <bits/stdc++.h>
#define oo(x) cout << x << " ";
#define o(x) cout << x << endl;
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 210;
int n, m;
int a[N];
int f[N][N];
bitset<N> st[N][N];
vector<int> ans;
int main() {
cin >> n;
for (int i = 1; i <= n; i ++ ) {
cin >> a[i];
m += a[i];
}
if (m % 2) puts("NO");
else {
m /= 2;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) {
if(j < a[i] || f[i - 1][j - a[i]] + a[i] <= f[i - 1][j])
f[i][j] = f[i - 1][j], st[i][j] = st[i - 1][j];
else
f[i][j] = f[i - 1][j - a[i]] + a[i], st[i][j] |= st[i - 1][j - a[i]], st[i][j][i] = 1;
}
if (f[n][m] == m) {
puts("YES");
for (int i = 1; i <= n; i ++ )
if (st[n][m][i]) cout << a[i] << " ";
else ans.push_back(a[i]);
cout << endl;
for (auto it : ans) cout << it << " "; cout << endl;
}
else puts("NO");
}
return 0;
}
1111111
最新推荐文章于 2024-09-15 11:40:06 发布