标签:
2 2 1 10 3 2 5 4
Case #1: 0 Case #2: 1
#include <iostream> #include<stdio.h> #include<math.h> #include<string.h> #include<algorithm> using namespace std; #define N 100005 #define LL __int64 int a[N]; int b[N]; int fun(int n) { int i,t,cnt=0; for(i=0;i<n;i++) { t=upper_bound(b,b+cnt,a[i])-b; //printf("%d \n",t); if(t==cnt) cnt++; b[t]=a[i]; } return cnt; } int main() { int i,T,n,cnt=1; scanf("%d",&T); while(T--) { scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); a[i]-=i; } printf("Case #%d:%d\n",cnt++,n-fun(n)); } return 0; }
标签:
原文地址:http://blog.csdn.net/u011721440/article/details/46382867