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

各位大侠看下我的程序吧。。所有能见到的数据都过了。。就是wa

Posted by 523093646 at 2012-12-19 20:10:05 on Problem 3183
#include <iostream>
using namespace std;
int main()
{
    int i,k,n,max,flag,f;
    int a[60001],v1[60001],v2[60001];
    int ans[60001];
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];

        v1[i]=v2[i]=1;
    }
    for (i=2;i<=n;i++)
    {
        if (a[i]>a[i-1]) v1[i]+=v1[i-1];
    }
    for (i=n-1;i>=1;i--)
    {
        if (a[i]>a[i+1]) v2[i]+=v2[i+1];
    }
    for (i=1;i<=n;i++)
    {
        v1[i]+=v2[i]-1;
    }
    k=n;
    f=0;
    while (k>0)
    {
        max=0;
        flag=0;
        for (i=1;i<=n;i++)
        {
            if (v1[i]>max)
            {
                max=v1[i];
                flag=i;
            }
        }
        if (a[flag-v1[flag]+v2[flag]-1]>a[flag-v1[flag]+v2[flag]])
        {
            v1[flag-v1[flag]+v2[flag]-1]--;
            v2[flag-v1[flag]+v2[flag]-1]--;
        }
        if (a[flag+v2[flag]]>a[flag+v2[flag]-1])
        {
            v1[flag+v2[flag]]--;
        }
        for (i=flag-v1[flag]+v2[flag];i<=flag+v2[flag]-1;i++)
        {
            v1[i]=0;
        }
        f++;
        ans[f]=flag;
        k-=max;
    }
    for (i=1;i<=f;i++)
    for (k=i+1;k<=f;k++)
    if (ans[i]>ans[k])
    {
        flag=ans[i];
        ans[i]=ans[k];
        ans[k]=flag;
    }
    for (i=1;i<=f;i++)
    {
        cout<<ans[i];
        if (i!=f) cout<<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