提交时间:2023-12-17 14:28:38
运行 ID: 116561
#include<bits/stdc++.h> using namespace std; int main(){ int n,a[205],sum=0,dp[20005]; memset(a,0,sizeof(a)); memset(dp,0,sizeof(dp)); cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; dp[a[i]]=a[i]; sum+=a[i]; } if(sum%2){ cout<<"false"; return 0; } sum/=2; for(int i=1;i<=n;i++){ for(int j=a[i];j<sum;j++){ dp[j]=max(dp[j],dp[j-a[i]]+a[i]); } } if(dp[sum]=sum){ cout<<"true"; } else cout<<"false"; return 0; }