代码:
#include#include #include using namespace std;int a[5005];int dp[130005];int main(){ int n; while(scanf("%d",&n)&&n>=0) { int k=1; int s=0; for(int i=0;i =0;v--) { dp[v]=max(dp[v],dp[v-a[i]]+a[i]); } } printf("%d %d\n",ss-dp[s],dp[s]); } return 0;}