题库练习 Joysticks
← 上一题 下一题 →

A10303 | Joysticks

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at $a_{1}$ percent and second one is charged at $a_{2}$ percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger).

Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops.

Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than $100$ percent.

输入格式

The first line of the input contains two positive integers $a_{1}$ and $a_{2}$ ( $1<=a_{1},a_{2}<=100$ ), the initial charge level of first and second joystick respectively.

输出格式

Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged.

输入输出样例

输入 #1
3 5
输出 #1
6
输入 #2
4 4
输出 #2
5
C++ 编辑器
输入
输出