Jump it up Solution | CodeChef [Easy]


Three dinos go on a camping trip. There they decide to play a game. They mark distances of 1 km each on the ground up to 100 km i.e. 1, 2, 3…100. They can sit only on these 100 spots, with each one at a different spot. In one move, one of the outer dinos can hop into a spot between the other two. Help them maximise their duration of play.

CodeChef Problem Link


Three numbers(integers), l, m and n (0 < l < m < n < 100), the starting spots of the dinosaurs.


Output the largest number of jumps the dinosaurs can make in all.

  • 0 < l < m < n <  100
Sample Input
5 6 11
Sample Output

Greedy Approach: Choose the maximum distance between the dinosaurs among 1st & 2nd and 2nd & 3rd.

Code Implementation

//  main.cpp
//  Jump it up
//  Created by Himanshu on 16/04/22.

#include <iostream>
using namespace std;

int main() {
    int a, b, c;
    if ((b-a)>(c-b)) {
    } else {
    return 0;

Time Complexity: O(1)

Leave a Reply

Your email address will not be published. Required fields are marked *