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 |
不会rmq,暴力672ms ac 付代码#include <iostream> using namespace std; int num[50001]; int main() { int count; while(cin>>count) { int i=0; int res=0; int index; for(int j=0;j<count;j++) scanf("%d",num+j); while(i<count-1) { int mymax=num[i]; index=i; int j; for(j=i+1;j<count;j++) { if(num[j]<=num[i]) { if(index==i) i++; else i=index+1; break; } else if(num[j]<=mymax) { if(j==count-1) i=index+1; continue; } else { if(j-i>res) res=j-i; mymax=num[j]; index=j; } if(j==count-1) i=index+1; } } if(res==0) printf("-1\n"); else printf("%d\n",res); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator