Sunday, May 1, 2016

UVA problem 11764 - Jumping Mario

Problem link (Click here)

#include<cstdio>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int test_case, c = 0;
    cin >> test_case;
    while(test_case--)
    {
        int total_wall, wall_height, wall = 0;
        int high_jump = 0;
        int low_jump = 0;
        c++;
        cin >> total_wall;
        while(total_wall--)
        {
            cin >> wall_height;
            if (wall == 0)
                wall = wall_height;
             else if(wall>wall_height)
                {
                    low_jump++;
                    wall = wall_height;
                }
             else if (wall<wall_height)
             {
                 high_jump++;
                 wall = wall_height;
             }
        }
        printf("Case %d: %d %d\n",c,high_jump,low_jump);
    }
    return 0;
}

No comments:

Post a Comment