# CodeChef : April LoC Competitive Programming Marathon – Decision Review System

By | April 28, 2017
##### Decision Review System

Source: CodeChef

It was a long home season for team India in test cricket. Below are few basic details of Test cricket.

• Test cricket is played over 5 days. Each day having 90 overs.
• Each over consist of 6 balls. Suppose we are in 21st over, all 6 balls will be represented as 20.1, 20.2, 20.3, 20.4, 20.5, 20.6
• Decision Review System(DRS) is available to team to challenge umpire’s decision. Initially each team has 2 reviews. Every unsuccessful use of DRS deducts 1 review whereas successful use of DRS doesn’t cause any deduction from remaining chances.
• After every 80 overs (i.e. after 79.6, 159.6 and so on), number of chance to use DRS are set to 2 for each team.

Quite unexpectedly team India batted for all 5 days. They had to use many reviews as umpire’s are human being and bound to make mistakes. Can you tell in worst case how many reviews used by India may have gone unsuccessful? You may assume that there infinite number of batsman in team.

### Input

• The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
• The first line of each test case contains a single integer N denoting the number of reviews used.
• Each of next N lines contain a ball number of the form O.B

### Output

• For each test case, output a single line containing the maximum number of unsuccessful reviews made .

You may assume that all the balls are given in strictly increasing order

### Example

```Input:
2
2
10.5
19.6
3
0.5
75.6
83.4

Output:
2
3```

### Explanation

Example case 1. Initially there are 2 reviews available. Team India uses review on 10.5 ball and it is unsuccessful. Now there is 1 review available. Now again review made on 19.6 ball is unsuccessful. Review remaining is 0. Number of unsuccessful review made is 2.

Example case 2. Initially there are 2 reviews available. Team India uses review on 0.5 and 75.6 ball and both are unsuccessful. Now review remaining is 0. After 80 over (i.e after 79.6 ball) reviews are set to 2. Again team India uses review on 83.4 ball and it is also unsuccessful. Review available is 1 and number of unsuccessful review made = 3.

### Solution

```This one seems tricky, but is pretty straight forward.
Hint: Just check conditions.
package aprilLoCCompetitiveProgrammingMarathon;

import java.util.Scanner;

public class DecisionReviewSystem {

public static void main(String[] args) {
Scanner scan= new Scanner(System.in);

int t=scan.nextInt();
for(int i=0;i<t;i++)
{
int n=scan.nextInt();
int count1=0, count2=0,count3=0, count4=0, count5=0, count6=0;
for(int j=0; j<n;j++)
{
float x=scan.nextFloat();
if(x<=79.6)
count1++;
else if(80.1<=x && x<=159.6)
count2++;
else if(160.1<=x && x<=239.6)
count3++;
else if(240.1<=x && x<=319.6)
count4++;
else if(320.1<=x  && x<=399.6)
count5++;
else if(400.1<=x  && x<=449.6) count6++; else {} } if(count1>2)
count1=2;
if(count2>2)
count2=2;
if(count3>2)
count3=2;
if(count4>2)
count4=2;
if(count5>2)
count5=2;
if(count6>2)
count6=2;
System.out.println(count1+count2+count3+count4+count5+count6);
}

}

}

```