Description
Input
Output
Sample Input
Sample Output
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstring> 5 using namespace std; 6 int main() 7 { 8 int n; 9 int a[1009]; 10 short visited[1009][1009]; 11 int i,j,t; 12 while(cin>>n) 13 { 14 for(i=1;i<=n;i++) 15 cin>>a[i]; 16 int ans=0; 17 memset(visited,0,sizeof(visited)); 18 for(i=1;i<=n;i++) 19 { 20 int sum=0; 21 t=30001; 22 for(j=1;j<=n;j++) 23 { 24 if(t>=a[j]&&visited[j][a[j]]==0) 25 { 26 visited[j][a[j]]=1; 27 t=a[j]; 28 sum++; 29 } 30 } 31 if(sum>0) 32 ans++; 33 34 } 35 cout<<ans<<endl; 36 } 37 }
原文:http://www.cnblogs.com/Aa1039510121/p/5693334.html