Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## WA。。。。。。不知为什么。路过的大牛帮忙看看

Posted by xiadaxue at 2010-05-25 18:29:05 on Problem 2559
```#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;

struct a
{
long long num;
long long s;
};
typedef struct a qq;
stack<qq>q;
stack<qq>z;
int main()
{
long long n,m[10000]={0},max,ans[10000]={0},size=0;;
qq scan[10000];

while(1)
{
qq e,l;
scanf("%lld",&n);
if(n==0)break;
for(int i=0;i<n;i++)
{
scanf("%lld",&scan[i].num);
scan[i].s=i+1;
}
e.num=-1;
e.s=n+1;
l.num=-1;
l.s=0;
q.push(e);
z.push(l);
for(int i=n-1;i>=0;i--)
{
while(scan[i].num<=q.top().num)q.pop();
m[i]=q.top().s-scan[i].s-1;
q.push(scan[i]);
}
max=0;
for(int i=0;i<n;i++)
{
while(scan[i].num<=z.top().num)z.pop();
int w=(m[i]+scan[i].s-z.top().s)*scan[i].num;
if(w>max)max=w;
z.push(scan[i]);
}
ans[size++]=max;
}
for(int i=0;i<size;i++)cout<<ans[i]<<endl;
return 0;
}```

Followed by: