标签:
1 5 1 4 7 6 2
5
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int T,n,i,a[100005],b[100005]; 6 int m_ax,sum; 7 scanf("%d",&T); 8 while(T--) 9 { 10 memset(b,0,sizeof(b)); 11 scanf("%d",&n); 12 for(i=1; i<=n; i++) 13 scanf("%d",&a[i]); 14 m_ax=a[1]; 15 sum=0; 16 for(i=1; i<=n; i++) 17 { 18 if(a[i]>=m_ax) 19 { 20 m_ax=a[i]; 21 sum++; 22 b[i]=1; 23 } 24 } 25 m_ax=a[n]; 26 for(i=n; i>0; i--) 27 { 28 if(a[i]>=m_ax) 29 { 30 m_ax=a[i]; 31 if(b[i]==0) 32 sum++; 33 } 34 } 35 printf("%d\n",sum); 36 } 37 return 0; 38 }
标签:
原文地址:http://www.cnblogs.com/liuwt365/p/4174633.html