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:我的怎么老是超时???哪位大哥大姐帮帮看看!!!In Reply To:我的怎么老是超时???哪位大哥大姐帮帮看看!!! Posted by:tzj115 at 2007-08-01 21:50:17 > # include <iostream.h> > > int n; > > int s[50010]; > int r[50010]; > > void des(int i) > { > if(i>0 && s[i-1]<s[i] && s[i-1]) > des(i-1); > if(i<n-1 && s[i+1]<s[i] && s[i+1]) > des(i+1); > s[i]=-1; > } > > int first() > { > int f; > int i=0; > while(s[i]==-1 && i<n) > ++i; > if(i>=n) > return -10; > while(s[i]<s[i+1] && i+1<n) > ++i; > return i; > } > > int main() > { > int t=0; > int wei; > > cin>>n; > while(t<n) > { > cin>>s[t++]; > } > t=0; > wei=first(); > while(wei>=0) > { > r[t++]=wei+1; > des(wei); > wei=first(); > } > for(int k=0;k<t;k++) > cout<<r[k]<<"\n"; > return 0; > } > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator