提交时间:2023-04-12 13:25:32

运行 ID: 74154

/* * __----~~~~~~~~~~~------___ * . . ~~//====...... __--~ ~~ * -. \_|// |||\\ ~~~~~~::::... /~ * ___-==_ _-~o~ \/ ||| \\ _/~~- * __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ * _-~~ .=~ | \\-_ '-~7 /- / || \ / * .~ .~ | \\ -_ / /- / || \ / * / ____ / | \\ ~-_/ /|- _/ .|| \ / * |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ * ' ~-| /| |-~\~~ __--~~ * |-~~-_/ | | ~\_ _-~ /\ * / \ \__ \/~ \__ * _--~ _/ | .-~~____--~-/ ~~==. * ((->/~ '.|||' -_| ~~-/ , . _|| * -_ ~\ ~~---l__i__i__i--~~_/ * _-~-__ ~) \--______________--~~ * //.-~~~-~_--~- |-------~~~~~~~~ * //.-~~~--\ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * \|/ */ #include<stdio.h> #include<iostream> #include<stack> using namespace std; const int N=1e5+10,INF=0x3f3f3f3f; inline int read(char ch=getchar(),int n=0,int m=1) { while(ch<'0' or ch>'9') { if(ch=='-')m=-1; ch=getchar(); } while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-'0',ch=getchar(); return n*m; } ostream& operator <<(ostream& o,__uint128_t &a) { __uint128_t x=a; stack<int>s; while(x)s.push(x%10),x/=10; while(!s.empty())o<<s.top(),s.pop(); return o; } int t=read(); signed main() { for(int i=1;i<=t;i++) { int n=read(),a[N],f[N],sum=-INF; for(int j=1;j<=n;j++)a[j]=read(); for(int j=1;j<=n;j++) { f[j]=1; for(int k=1;k<j;k++) { if(a[k]-k<=a[j]-j)f[j]=max(f[j],f[k]+1); sum=max(sum,f[j]); } } cout<<"Case #"<<i<<":\n"<<n-sum<<"\n"; } return 0; }