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

Re:嘿嘿,用时一样

Posted by ccsu2008021220 at 2009-10-04 22:31:48 on Problem 1631
In Reply To:AC 了 110ms~ Posted by:810974380 at 2009-08-25 15:54:46
之前做过一个一样的题,改一下就过了……

贴代码:

#include<iostream>
#include<stdio.h>
using namespace std;
int a[400001],dp[400001];
int main()
{
    int m;
    scanf("%d",&m);
    while(m--)
    {     
        int num1=1;
        int i;
        int n;
        scanf("%d",&n);
        int max;
        int p,r;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&r);
            a[i]=r;
        }
        dp[1]=a[1];
        max=1;
        int low,hight,mid;
        for(i=2; i<=n; i++)
        {
            low=0;
            hight=max;
            while(low<=hight)
            {
                mid=(low+hight)/2;
                if(a[i]>dp[mid])
                    low=mid+1;
                else
                    hight=mid-1;
            }
            dp[low]=a[i];
            if(low>max)
                max++;
        }
        int num=max;
        cout<<num<<endl;
    }
    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