a800: Joysticks ( 操縱桿 )
Tags : 1100
Accepted rate : 16人/16人 ( 100% ) [非即時]
評分方式:
Tolerant

最近更新 : 2022-08-14 23:24

Content

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 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.

朋友要去玩控制台。 他們有兩個操縱桿,只有一個充電器。 最初,第一個操縱桿以 a1% 的速度充電,第二個操縱桿以 a2% 的速度充電。 您只能在每分鐘開始時將充電器連接到操縱桿。 在一分鐘內,操縱桿會放電 2%(如果未連接到充電器)或充電 1%(如果連接到充電器)。

當兩個操縱桿都帶有正電荷時,遊戲繼續進行。 因此,如果在遊戲開始時某個操縱桿充電了 1%,則必須將其連接到充電器,否則遊戲將停止。 如果某個操縱桿完全放電(其電量變為 0),遊戲也會停止。

確定遊戲可以持續的最大分鐘數。 禁止暫停遊戲,例如:每時每刻都應啟用兩個操縱桿。 允許操縱桿充電超過 100%。

Input

The first line of the input contains two positive integers a1 and a2 (1 ≤ a1, a2 ≤ 100), the initial charge level of first and second joystick respectively.

輸入的第一行包含兩個正整數a1和a2(1 ≤ a1, a2 ≤ 100),分別是第一和第二操縱桿的初始充電水平。

Output

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

輸出唯一的整數,即遊戲可以持續的最大分鐘數。 遊戲繼續進行,直到一些操縱桿被釋放。

Sample Input #1
3 5
Sample Output #1
6
Sample Input #2
4 4
Sample Output #2
5
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (4%): 1.0s , <1K
公開 測資點#1 (4%): 0.4s , <1K
公開 測資點#2 (4%): 0.4s , <1K
公開 測資點#3 (4%): 0.4s , <1K
公開 測資點#4 (4%): 0.4s , <1K
公開 測資點#5 (4%): 0.4s , <1K
公開 測資點#6 (4%): 0.4s , <1K
公開 測資點#7 (4%): 0.4s , <1K
公開 測資點#8 (4%): 0.4s , <1K
公開 測資點#9 (4%): 0.4s , <1K
公開 測資點#10 (4%): 0.4s , <1K
公開 測資點#11 (4%): 0.4s , <1K
公開 測資點#12 (4%): 0.4s , <1K
公開 測資點#13 (4%): 0.4s , <1K
公開 測資點#14 (4%): 0.4s , <1K
公開 測資點#15 (4%): 0.4s , <1K
公開 測資點#16 (4%): 0.4s , <1K
公開 測資點#17 (4%): 0.4s , <1K
公開 測資點#18 (4%): 0.4s , <1K
公開 測資點#19 (4%): 0.4s , <1K
公開 測資點#20 (4%): 0.4s , <1K
公開 測資點#21 (4%): 0.4s , <1K
公開 測資點#22 (4%): 0.4s , <1K
公開 測資點#23 (4%): 0.4s , <1K
公開 測資點#24 (4%): 0.4s , <1K
Hint :

In the first sample game lasts for 6 minute by using the following algorithm:

  • at the beginning of the first minute connect first joystick to the charger, by the end of this minute first joystick is at 4%, second is at 3%;
  • continue the game without changing charger, by the end of the second minute the first joystick is at 5%, second is at 1%;
  • at the beginning of the third minute connect second joystick to the charger, after this minute the first joystick is at 3%, the second one is at 2%;
  • continue the game without changing charger, by the end of the fourth minute first joystick is at 1%, second one is at 3%;
  • at the beginning of the fifth minute connect first joystick to the charger, after this minute the first joystick is at 2%, the second one is at 1%;
  • at the beginning of the sixth minute connect second joystick to the charger, after this minute the first joystick is at 0%, the second one is at 2%.

After that the first joystick is completely discharged and the game is stopped.

在第一個示例遊戲中,使用以下算法持續 6 分鐘:

在第一分鐘開始時,將第一個操縱桿連接到充電器,到這一分鐘結束時,第一個操縱桿處於 4%,第二個操縱桿處於 3%;
不換充電器繼續遊戲,第二分鐘結束時第一個搖桿為5%,第二個為1%;
在第三分鐘開始時將第二個操縱桿連接到充電器,這一分鐘後第一個操縱桿處於 3%,第二個操縱桿處於 2%;
不換充電器繼續遊戲,到第4分鐘第一個搖桿在1%,第二個搖桿在3%;
在第 5 分鐘開始時,將第一個操縱桿連接到充電器,這一分鐘之後,第一個操縱桿處於 2%,第二個操縱桿處於 1%;
在第六分鐘開始時,將第二個操縱桿連接到充電器,這一分鐘之後,第一個操縱桿處於 0%,第二個操縱桿處於 2%。
之後,第一個操縱桿完全放電,遊戲停止。

Tags:
1100
出處:
Codeforces Round #345 [管理者:
lamkinun@gma... (Kinda Lam)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」