黑人问号???
查看原帖
黑人问号???
23588
zsz12251665楼主2016/11/8 14:20
#include<cstdio>
int a[100],dec[100],max[100];
int intercept(int n)
{
    int i,j,back;
    max[0]=-1;
    if(a[0]==0)
        dec[0]=0;
    else
        dec[0]=1;
    for(i=1;i<n;i++)
        if(a[i]>0)
        {
            dec[i]=1;
            max[i]=-1;
            for(j=0;j<=i-1;j++)
                if((a[j]>0)&&(a[j]>=a[i])&&(dec[i]<dec[j]+1))
                {
                    dec[i]=dec[j]+1;
                    max[i]=j;
                }
        }
        else
            dec[i]=0;
    back=0;
    for(i=0;i<n;i++)
        if(dec[i]>back)
        {
            back=dec[i];
            j=i;
        }
    a[j]=0;
    while(max[j]!=-1)
    {
        j=max[j];
        a[j]=0;
    }
    return back;
}
int main()
{
    int n=0,k;
    while(scanf("%d",&a[n])!=EOF)
    {
        scanf("%d",&a[n]);
        dec[n++]=1;
    }
    printf("%d\n",intercept(n));
    k=1;
    while(intercept(n)>0)
        k++;
    printf("%d\n",k);
    return 0;
}
2016/11/8 14:20
加载中...