caravans problem - why i get wrong answer ?

hi , i tried to resolve the problem , and this is my code

#include <stdio.h>
#include <stdlib.h>
int main() {
int t;
int n;

scanf("%d",&t);
while (t--){
      int nb_cars = 0;
      int tmp;
      int low_vit=100000;
      scanf("%d",&n);
      int i;
      for(i=0;i<n;i++) {
          scanf("%d",&tmp);
              if(tmp<=low_vit) {
                  nb_cars++;
                  low_vit = tmp;
              }
      }
      printf("%d\n",nb_cars);  
}       
return 0;

}
so what’s the problem , thanks

here the problem set https://www.codechef.com/problems/CARVANS

There is nowhere given in question that the maximum possible speed is 100000. The limit for 32bit integer is not 100000. Now lets say first car to enter circuit is having maximum speed as 100005. So you doesn’t count this car because its bigger than 100000 but you can easily notice that first car to enter will always move at its maximum speed.

Hope this helps !!

1 Like

thank you a lot , that was the problem, i used INT_MAX .