#D3575. All Japan Association of Return home
All Japan Association of Return home
All Japan Association of Return home
problem
AOR Co., Ltd. (Association Of Return home) has employees.
Employee wants to use the elevator to go down to the floor and arrives in front of the elevator on the floor at time . You decide to remotely control an elevator that has only on the floor at time and send all employees to the floor. The elevator can only carry up to people. Elevators can move upstairs or stay in place per unit time. Employee only takes the elevator if the elevator is on the floor at time and does not exceed capacity. When I can't get on the elevator at time , I'm on the stairs to the floor. The time it takes to get on and off can be ignored.
Find the minimum total time each employee is in the elevator. However, if there are even people who cannot take the elevator to the floor, output .
output
Output the minimum total time each employee is in the elevator. However, if there are even people who cannot take the elevator to the floor, output . Also, output a line break at the end.
Example
Input
2 2 2 2 3 3
Output
5
inputFormat
outputFormat
output .
output
Output the minimum total time each employee is in the elevator. However, if there are even people who cannot take the elevator to the floor, output . Also, output a line break at the end.
Example
Input
2 2 2 2 3 3
Output
5
样例
2 2
2 2
3 3
5