Desks

Report a typo

A university has decided to open math courses and equip classrooms for 3 groups with new special desks. The faculty agreed that for the sake of productivity, only two students at most may share one desk.

The enrollment has ended and the university knows how many students are in each group. Now the task is to count the number of desks based on the number of students in each group. Of course, the university is short of money, so you need to calculate the minimum number of desks required for each group.

Keep in mind that each group will sit in its own separate classroom. For all classrooms, a desk can host at most two students. This means when the total number of students in a group is odd, the remaining student in that group gets to use the entire desk for themselves.

Input data format

The program receives the input of three non-negative integers: the number of students in each of the three groups (the numbers are not bigger than 1000).

Sample Input 1:

20
21
22

Sample Output 1:

32

Sample Input 2:

16
18
20

Sample Output 2:

27
Write a program in Java 17
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// put your code here
}
}

Create a free account to access the full topic