You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
563 B
C++

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=1e6+10;
int a[N],b[N];
int main()
{
int T,n,t=0;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=0; i<n; i++)
scanf("%d",a+i);
memcpy(b,a,sizeof(int)*n);
for(int i=n-1; i; i--)
b[i-1]=min(b[i-1],b[i]);
int ans=0;
for(int i=1; i<n; i++)
if(a[i-1]>b[i])
ans++;
printf("Case #%d: %d\n",++t,ans);
}
return 0;
}