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

好坑啊这题 !!!!!!!!!!!!!!!!!!!!!!!

Posted by nyist_L at 2016-04-11 19:59:46 on Problem 1836
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int eps=1e-9;
double a[2010],g[2010];
int d[2010],dd[2010];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%lf",&a[i]);
        }
       for(int i=1;i<=n+1;i++)
       {
           g[i]=1e9;
       }
        for(int i=1;i<=n;i++)
        {
            double w=a[i];
            int k=lower_bound(g+1,g+1+n,w-eps)-g;
            d[i]=k;
            g[k]=w;
        }
        for(int i=1;i<=n+1;i++)
       {
           g[i]=1e9;
       }
       for(int i=n;i>=1;i--)
       {
           double w=a[i];
           int s=lower_bound(g+1,g+n+1,w-eps)-g;
           dd[i]=s;
           g[s]=w;
       }
       int maxx=0;
       for(int i=1;i<=n;i++)
       for(int j=i+1;j<=n;j++)
       {
           if(dd[j]+d[i]>maxx)
           {
               maxx=d[i]+dd[j];
           }
       }
        printf("%d\n",n-maxx);
    }
}

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