# HackerEarth Speed problem solution

In this HackerEarth Speed, problem-solution Rash is known about his love for racing sports. He is an avid Formula 1 fan. He went to watch this year's Indian Grand Prix in New Delhi. He noticed that one segment of the circuit was a long straight road. It was impossible for a car to overtake other cars in this segment. Therefore, a car had to lower down its speed if there was a slower car in front of it. While watching the race, Rash started to wonder how many cars were moving at their maximum speed. Formally, you're given the maximum speed of N cars in the order they entered the long straight segment of the circuit. Each car will prefer to move at its maximum speed. If that's not possible because the front car is slow, it might have to lower its speed. It still moves at the fastest possible speed while avoiding any collisions. For the purpose of this problem, you can assume that the straight segment is infinitely long. Count the number of cars that were moving at their maximum speed on the straight segment.

## HackerEarth Speed problem solution.

`#include<iostream>#include<cstring>#include<string>#include<cstdio>#include<fstream>#include<cstdlib>#include<cassert>#include<vector>#include<algorithm>#include<stack>#include<set>#include<map>#include<list>#include<math.h>#include<ctime>#define LL long long#define ULL unsigned long long#define F first#define S second#define pb push_back#define FOR(i,lb,ub) for(i=lb;i<=ub;i++)#define RFOR(i,ub,lb) for(i=ub;i>=lb;i--)#define FORS(it,v) for(it=v.begin();it!=v.end();it++)#define st_clk double st=clock();#define end_clk double en=clock();#define show_time cout<<"\tTIME="<<(en-st)/CLOCKS_PER_SEC<<endl;#define sc(n) scanf("%d",&n)#define scst(n) scanf("%s",n)#define f_in(st) freopen(st,"r",stdin);#define f_out(st) freopen(st,"w",stdout);LL gcd(LL a, LL b) { return b?gcd(b,a%b):a; }using namespace std; int main(){     #ifndef ONLINE_JUDGE     #endif     int t,i,j;     cin>>t;     while (t--)     {        int n,tmp;        LL ans = 0;        cin>>n;        assert(n<10000);        FOR(i,0,n-1)        {            int x;            cin>>x;            if (!i)            {                tmp = x;                ans++;            }            else if (x<tmp)            {                tmp = x;                ans++;            }                                }        cout<<ans<<endl;     }return 0;}`