Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

wa的代码,请指错?

Posted by xf_zhen at 2016-07-29 20:52:40 on Problem 3688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;


int main()
{
    int n,m;
    int num[10005];
    bool dp[100010][2];
    while(scanf("%d %d",&n,&m)==2&&n)
    {
        memset(num,0,sizeof(num));
        memset(dp,false,sizeof(dp));
        for(int i=0;i<n;i++)
        {
            scanf("%d",&num[i]);
        }
        sort(num,num+n);
        int i,j;
        int ans = 0;
        for(i=0;i<n;i++)
            dp[num[i]][1] = true;
        for( i=1;i<n;i++)
        {
            for(j=m;j>num[i];j--)
            {
                if(dp[j-num[i]][0])
                    dp[j][1] = true;
                if(dp[j-num[i]][1])
                    dp[j][0] = true;
            }
        }
        for(i=1;i<=m;i++)
        {
            if(dp[i][1]&&(!dp[i][0]))ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator