King of cans
Time limit1sMemory limit1024 MB
Given x bottles worth 2 kroner and y bottles worth 3 kroner, find the maximum number of groups that each sum to exactly 100.
- Level
Medium4 of 10
- Topics
- Math, Greedy, Brute force, Implementation
- Solved
- No attempts yet
Problem
Lisa, an informatics student at the University of Bergen in Norway, has spent far too much money. To make up for it, she has decided to recycle the empty cans she found in the reading hall. Since Lisa has been in Norway for a while now, she knows that the Norwegian government runs a deposit-refund scheme to encourage recycling of soda bottles: when buying a bottle, the store collects an extra or Norwegian kroner in deposit, depending on bottle size, for each soda bottle you buy. If someone returns an empty bottle to the store to be recycled, the deposit is refunded to the redeemer. So if Lisa manages to find a couple of hundred bottles left behind by wasteful students, it can quickly become surprisingly much money.
As an informatics student, Lisa naturally has some tendencies of OCD, and today it kicks in hard. She will not take any receipt that is not exactly Norwegian kroner after recycling the soda. The question is this: what is the maximum amount of receipts equaling exactly Norwegian kroner Lisa can get?
Input
The first and only line has two space-separated integers and , where is the number of bottles whose deposit worth is Norwegian kroner, and is the number of bottles whose deposit is worth Norwegian kroner.
Output
Your program should output a single integer, the maximum number of refund receipts Lisa can get which each total exactly Norwegian kroner.