1 #include<cstdio> 2 #define MAXN 100010 3 int st[MAXN]; 4 int main() 5 { 6 bool flag; 7 int n,i,x,top,ans,ca=1; 8 while(~scanf("%d",&n)) 9 { 10 for(top=-1,ans=i=0;i<n;i++) 11 { 12 flag=true; 13 scanf("%d",&x); 14 for(;top>-1&&st[top]>=x;top--) 15 { 16 if(st[top]==x) 17 flag=false; 18 } 19 st[++top]=x; 20 if(flag&&x) 21 ans++; 22 } 23 printf("Case %d: %d\n",ca++,ans); 24 } 25 return 0; 26 }
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)