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 |
求数据啊,为什么一直是wrong answer?#include<stdio.h> const int maxp=150005; int potion[maxp],mark[maxp]; int main() { int p,maxj=0,step=0,k=0; scanf("%d",&p); for(int i=0;i<p;i++) { scanf("%d",&potion[i]); mark[i]=0; } while(k<p) { if(step%2==0) { while(potion[k]<=potion[k+1]) k++; mark[k]=1; step++; } else { while(potion[k]>=potion[k+1]) k++; mark[k]=-1; step++; } } for(int i=p-1;i>=0;i--) if(mark[i]==1) break; else if(mark[i]==-1) { mark[i]=0; break; } for(int i=0;i<p;i++) maxj+=potion[i]*mark[i]; printf("%d\n",maxj); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator