CARVANS - Editorial

what is wrong in this question

please help me

#include
using namespace std;

int main()
{
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int a[n+1];
for(int i=1;i<=n;i++){
cin>>a[i];

    }
    int ans=0;
    a[0]=-1;
    for(int i=1;i<=n;i++){
        if(a[i]<a[i-1]) ans++;
    }
    cout<<ans<<endl;
}
return 0;

}

“”“This approach works too ,and is faster than other appraoches mentioned above”""
“”“AC in one go”""

test=int(raw_input())
for _ in range(test):
N=int(raw_input())
count=1
arr=list()
arr=[int(i) for i in raw_input().split()]
for i in range(len(arr)-1):
	if(arr[i+1]>arr[i]):
		arr[i+1]=arr[i]
	else:
		count+=1
print count

can some one find mistake in this code

import java.util.;
import java.lang.
;
import java.io.*;
class klf
{
public static void main(String[]args) throws Exception
{
Scanner cin=new Scanner(System.in);
Stackst;
int t=cin.nextInt();
while(t–>0)
{
st=new Stack();
int n=cin.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=cin.nextInt();
}
int count=0;
for(int i=0;i<n;i++)
{
if(st.empty())
{
st.push(a[i]);
count++;
}
else if(a[i]<st.peek())
{
st.push(a[i]);
count++;
}
else
{
st.push(a[i]);
}
}
while(!st.empty())
st.pop();
System.out.println(count);
}
}
}

strong text
Can anybody please let me know what is wrong with my code…
strong text
#include<stdio.h>

int main(){
int rounds,cars,speed,count=0;
for(scanf("%d",&rounds);rounds;rounds–){
int min=10000;
count=0;
for(scanf("%d",&cars);cars;cars–){
scanf("%d",&speed);
if(speed<=min){
count++;
min=speed;
}
}
printf("%d\n",count);

}

return 0;

}

Does Input to this problem is in file?
Am i need to take input from files?

Just have a look : https://www.codechef.com/viewsolution/22546307,
You will not need an array!