Getting WA please check (CARVAN)

https://www.codechef.com/viewsolution/31210763

Check the order in which cars are entering into the track from the sample examples. Is it left to right or right to left, please check.

you are getting wrong answer as in test case
4 5 1 2 3
second car will be restricted to speed of 4 so you have to copy speed accordingly as a[i+1]=a[i].

1 Like

i have checked that …

can u plzz update my code…

you are doing a[i]=a[i+1] instead of a[i+1]=a[i];

2 Likes

still getting wrong answer for last test case

Here is my code,getting wrong output for
last test case
#include<stdio.h>

#include<stdlib.h>

#include<stdbool.h>

#include<string.h>

#include<math.h>

#include<limits.h>

#include<time.h>

int main()

{

int n,t,car_speed[501];

scanf("%d",&t);

while(t--)

{

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",car_speed);

    }

    int car_count=1;

    for(int i=0;i<n-1;i++)

    {

               

        if(car_speed[i]<car_speed[i+1])

            car_speed[i+1]=car_speed[i];

          

        else

            car_count++;   

    }

    printf("%d\n",car_count);

}

return 0;

}

as 1 ≤ N ≤ 10,000 so you have to increase your array size.

i increased the array size but still im getting answer.