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 3013216027 at 2014-11-30 15:49:57 on Problem 3903
In Reply To:一直超时,哎·· Posted by:huxipeng at 2014-01-01 20:27:18
> #include<iostream>
> #include<string.h>
> using namespace std;
> 
> int dp[100000];
> int  a[100000];
> int main()
> {
>     int n;
> 	cin>>n;
> 	while(cin>>n)
> 	{
> 		int longlist=1;
> 	    for(int i=1;i<=n;i++)
> 		{
> 		     cin>>a[i];
> 		}
> 		memset(dp,1,sizeof(dp));
> 		for(int i=2;i<=n;i++)
> 		{
> 		   for(int j=1;j<i;j++)
> 		   {
> 		        if(a[j]<a[i])
> 					dp[i]=max(dp[j]+1,dp[i]);
> 
> 		   }
> 		   longlist=max(dp[i],longlist);
> 		}
>      cout<<longlist<<endl;
> 	}
> 	return 0;
> }
数据较大,需要O(n logn)的LIS算法

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