Sunday 26 August 2018

Broctagon Fintech Software Engineer Challenge

Broctagon Fintech Software Engineer Challenge


Red and Blue Rangers
Red and Blue Rangers are sent for a fight. Each ranger has a power where it can only kill the villans who have powers in their range.

More precisely, Red ranger is given a range of 1 to A, both inclusive and Blue ranger is given a range of B to C both inclusive. To make sure that villans don't predict this range, following constraints hold-
1 <= B <= C
B <= A <= C


and if a ranger fights a villan with power x, only he should fight all the villans who have power x ie if Red ranger decides to fight a villan with power 2 then he has to fight with all the villans who have power 2.

Each ranger fights one at a time. It takes 1 min to kill a villan and 2 mins to switch places.
Ranger would like to kill all villans as fast as possible. Find the minimum time that is needed to kill all the villans.

Input
3 2 2
6
1 2 3 2 1 2

Output
10

Red ranger can kill villans with power 1 and 2
Blue ranger can kill villans with power 2 and 3



Garry and points
A coder I is better than coder J if and only if both of coder I's points are greater than or equal to J's corresponding points, with atleast one being greater. For each coder I, determine how many coders coder I is better than.
For every input file, you need to determine the number of lines present to find number of participants.

Input
1798 1832
862 700
1075 1089

Output
2
0
1

Explaination
There are 3 players. Player 1 is better than 2 and 3, Player 2 is not better than anyone, player 3 is better than player 2

Input
1656 1649
1014 1473

Output
1
0

No comments :

Post a Comment