intmain() { int T; scanf("%d",&T); while (T--) { int n; scanf("%d",&n); for (int i=1;i<=n;++i) scanf("%d",a+i); int ans=max(n-2,0); for (int i=1;i<=n;++i) for (int j=i+1;j<=n;++j) { double d=((double)a[j]-a[i])/(j-i); int cnt=0; for (int k=1;k<=n;++k) if (!equal(a[i]-(i-k)*d,a[k])) ++cnt; ans=min(ans,cnt); } printf("%d\n",ans); } }
intmain() { int T; scanf("%d",&T); while (T--) { int n; scanf("%d",&n); for (int i=1;i<=n;++i) scanf("%d",a+i); int x; scanf("%d",&x); for (int i=1;i<=n;++i) a[i]-=x; memset(f,0,sizeof(f)); for (int i=1;i<=n;++i) { f[i][0][0][0]=max(f[i-1][1][0][0],f[i-1][0][0][0]); f[i][0][0][1]=max(f[i-1][1][0][0],f[i-1][0][0][0])+1; f[i][0][1][0]=max(f[i-1][1][0][1],f[i-1][0][0][1]); f[i][0][1][1]=0; if (a[i-1]+a[i]>=0) f[i][0][1][1]=max(f[i-1][0][0][1],f[i-1][1][0][1])+1; f[i][1][0][0]=max(f[i-1][0][1][0],f[i-1][1][1][0]); f[i][1][0][1]=max(f[i-1][0][1][0],f[i-1][1][1][0])+1; f[i][1][1][0]=max(f[i-1][0][1][1],f[i-1][1][1][1]); f[i][1][1][1]=0; if (i>2 && a[i-2]+a[i-1]+a[i]>=0 && a[i-1]+a[i]>=0) f[i][1][1][1]=max(f[i-1][0][1][1],f[i-1][1][1][1])+1; } int ans=0; for (int i=1;i<=n;++i) for (int j=0;j<=1;++j) for (int k=0;k<=1;++k) for (int w=0;w<=1;++w) ans=max(ans,f[i][j][k][w]); printf("%d\n",ans); } }