| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:一直超时,哎··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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator