http://acm.hdu.edu.cn/showproblem.php?pid=1257
找数列中递减数列的个数....
View Code
1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 const int maxn=1000005; 5 int ans[maxn],num; 6 bool f[maxn]; 7 int main() 8 { 9 int n,i,t,j; 10 while(~scanf("%d",&n)){ 11 for(i=0;i<n;i++) 12 { 13 scanf("%d",&ans[i]); 14 f[i]=0; 15 } 16 num=0; 17 for(i=0;i<n;i++) 18 if(!f[i]){ 19 num++; 20 t=i; 21 for(j=i;j<n;j++) 22 if(f[j]!=1 && ans[j]<=ans[t]) 23 { 24 t=j; 25 f[j]=1; 26 } 27 } 28 printf("%d\n",num); 29 } 30 return 0; 31 }