#include
#include
using namespace std;
int main() {
// your code goes here
long long int t,n;
cin>>t;
while(t–){
cin>>n;
vector a;
int temp=0;
int car=1;
for(int i=0;i<n;i++){
cin>>temp;
a.push_back(temp);
}
if(n==1)
cout<<"1"<<endl;
else{
for(int i=1;i<n;i++){
if(a[i]<a[i-1])
car++;
}
cout<<car<<endl;}
}
return 0;
}
Hello @ankyytt, Welcome to Codechef Community.
Please mention the reason why you’ve posted the code and a link, so that the community can help if you need.
1 Like
I think you are unable to solve this problem. I have seen your submission, and modified a little bit. And here’s the AC code.
#include <iostream>
#include<vector>
using namespace std;
int main() {
// your code goes here
int t,n;
cin>>t;
while(t--){
cin>>n;
vector <int> a;
int temp=0;
for(int i=0;i<n;i++){
cin>>temp;
a.push_back(temp);
}
int min = a[0];
int car=1;
for(int i=1;i<n;i++){
if(a[i]<min) {
min = a[i];
car++;
}
}
cout<<car<<endl;
}
return 0;
}
1 Like