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:why WA????? I think my code is right

Posted by foolfish at 2008-04-04 15:02:53 on Problem 2796
In Reply To:why WA????? I think my code is right Posted by:foolfish at 2008-04-04 15:00:01
> #include<iostream>
> #include<stdio.h>
> using namespace std;
> 
> int n,i;
> struct point 
> {
>     int left,right;
> };
> 
> __int64 list[100005];
> point flag[100005];
> 
> void search(int r )
> {
>      if(list[i]>list[i-1])
>          flag[i].left=i;
>      else flag[i].left=flag[i-1].left;
>      
>      if(list[i]>list[r+1])
>          flag[i].right=r;
>      else search(r+1);
> }
> 
> int main()
> {
>     __int64  Max,haha;
>     __int64  sum[100005];
>     int k,j;
>     while(scanf("%d",&n)==1)
>     {
>         list[0]=list[n+1]=-1;
>         sum[0]=0;
>         for(i=1;i<=n;i++)
>         {
>             scanf("%I64d",&list[i]);
>             sum[i]=sum[i-1]+list[i];
>         }
>         Max=-1;
>         for(i=1;i<=n;i++)
>         {
>             search(i);
>             haha=(sum[flag[i].right]-sum[flag[i].left-1]);
>             if(Max<=haha*list[i])
>             {
>                 Max=haha*list[i];
>                 k=i;
>             }         
>         }       
>         printf("%I64d\n",Max);
>         printf("%d %d\n",flag[k].left,flag[k].right);
>     }
>     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