提交时间:2023-12-08 13:36:41
运行 ID: 114514
#include<bits/stdc++.h> #define int long long using namespace std; const int N = 1e6 + 9; int n , w[N] , dp[N]; int sum; signed main() { cin >> n; for(int i = 1;i <= n;i++) { cin >> w[i]; sum += w[i]; } for(int i = 1;i <= n;i++) for(int j = w[i];j <= sum / 2;j++) dp[j] = max(dp[j - w[i]] + w[i] , dp[j]); if(dp[sum / 2] == sum / 2 && sum % 2 == 0) cout << "true"; else cout << "false"; return 0; }