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:已解决……5600MS……

Posted by JokerKS at 2010-10-05 12:04:54 on Problem 2823
In Reply To:WA的代码…… Posted by:JokerKS at 2010-10-04 15:08:11
> #include<stdio.h>
> int n,dp[1100000],dps[1100000],s[1100000],k;
> void work()
> {
>     int i,j,p,q,m;
>     for(j=2;j<=k;j*=2)
>         for(i=1,p=j;p<=n;i++,p++)//应该是p=j/2+1
>            {
>             if(dp[p]>dp[i])  dp[i]=dp[p];
>             if(dps[p]<dps[i])dps[i]=dps[p];
>            }
>     j/=2;
>     for(i=1,p=k-j+1,m=n-k+1;i<=m;i++,p++)
>             printf("%d ",dps[i]<dps[p]?dps[i]:dps[p]);
>     printf("\n");
>     for(i=1,p=k-j+1,m=n-k+1;i<=m;i++,p++)
>             printf("%d ",dp[i] > dp[p]? dp[i]: dp[p]);
>     printf("\n");
> }
> int main()
> {
>     int i,j;
>     scanf("%d %d",&n,&k);
>     if(k==1)
>        {
>         for(i=1;i<n;i++)
>             {
>              scanf("%d",&s[i]);
>              printf("%d ",s[i]);
>             }
>         scanf("%d",&s[n]);
>         printf("%d\n",s[n]);
>         for(i=1;i<n;i++)printf("%d ",s[i]);
>         printf("%d\n",s[n]);
>         return 0;
>        }
>     for(i=1;i<=n;i++)
>         {
>          scanf("%d",&s[i]);
>          dp[i]=dps[i]=s[i];
>         }
>     work();
>     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