Help in debugging Codechef — Carvans

Правка en3, от ghoshsai5000, 2017-06-26 05:50:06

Here is the link for the problem with CodeChef problem Carvans.

Here's my solution. ... I am unable to find any bugs. Please help me debug it and tell me what is wrong with it.

#include <stdio.h>
#include <algorithm>

using namespace std;

void solve()
{
    int previous_car_speed = 1e9, current_car_speed, number_of_cars, current_car_max_speed;;
    scanf("%d", &number_of_cars);

   int no_of_cars_at_max_speed = 0;
    for(int i = 1; i <= number_of_cars; i++)
   {
        scanf("%d", &current_car_max_speed);

        current_car_speed = min(previous_car_speed, current_car_max_speed);

        no_of_cars_at_max_speed += (current_car_speed == current_car_max_speed);

        previous_car_speed = current_car_speed;
   }

   printf("%d\n", no_of_cars_at_max_speed);
}

 int main()
 {
    int no_of_test_cases;
    scanf("%d", &no_of_test_cases);

    while(no_of_test_cases--)
        solve();

    return 0;
}
Теги help, debug, codechef, implementation

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский ghoshsai5000 2017-06-26 05:50:06 45
en2 Английский ghoshsai5000 2017-06-25 17:27:32 4 Tiny change: ' }\n\n int main()\n {\n ' -> ' }\n\n int main()\n {\n '
en1 Английский ghoshsai5000 2017-06-25 17:25:52 1090 Initial revision (published)