| ||||||||||
| 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:why WA????? I think my code is rightIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator