Can't find where is the problem.

In this question my code is running fine according to the sample input and I can’t find where is the problem at my code . It’s showing wrong answer while submitting .

using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n;
	    cin>>n;
	    int arr[n];
	    for(int i=0; i<n; i++){
	        cin>>arr[i];
	    }
	    int ans=1;
	    for(int i=1; i<n; i++){
	        if(arr[i-1]>=arr[i]){
	            ans++;
	        }
	    }
	    cout<<ans<<"\n";
	    
	}
	return 0;
}

Hey, there are a lot of logical errors in your code. First of all, if any car before the current car is slower than it, it won’t be able to run on its max speed, to do this you need to add the statement

a[i] = min(a[i], a[i-1]

after the if condition in every statement and the code should pass.
Here I have done something similar and it has passed: https://www.codechef.com/viewsolution/61573614