| ||||||||||
| 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 | |||||||||
这样子为什么过不了??#include<stdio.h>
const int max=150005;
int potion[max],mark[max];
int main()
{
int p,max=0;
scanf("%d",&p);
for(int i=0;i<p;i++)
{
scanf("%d",&potion[i]);
mark[i]=0;
}
if(potion[0]>potion[1])
mark[0]=1;
if(potion[p-1]>potion[p-2])
mark[p-1]=1;
for(int i=1;i<p-1;i++)
{
if(potion[i]>potion[i-1]&&potion[i]>potion[i+1])
mark[i]=1;
if(potion[i]<potion[i-1]&&potion[i]<potion[i+1])
mark[i]=-1;
}
for(int i=0;i<p;i++)
max+=mark[i]*potion[i];
printf("%d\n",max);
}
输入的potion有没有可能相同的啊?
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator