The Hardest Part of Mahjong
InterviewTime limit1sMemory limit1024 MB
Split people who want 3-player, 4-player, or either game into 3-person and 4-person tables so everyone plays their preferred game, minimizing 3-player tables.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
The hardest part of mahjong is finding people to play with.
To solve this, you gathered a group of players, and a large crowd showed up.
Another problem is that people do not all play the same kind of mahjong. Three-player mahjong is played by three people, and four-player mahjong is played by four. Among the people you gathered, some want to play only three-player mahjong, some want to play only four-player mahjong, and others do not care as long as they can play mahjong.
Your new task is to split the people into groups of 3 or 4 so that everyone can play the kind they want. You must also set up tables to match each kind of mahjong. You do not consider three-player mahjong real mahjong, though. If more than one setup lets everyone play the kind they want, set up as few three-player tables as possible.
Find the number of three-player tables and the number of four-player tables you need to set up.
Input
The first line contains three integers , , and , separated by spaces. They are the number of people who want to play only three-player mahjong, the number who want to play only four-player mahjong, and the number who do not care.
(; )
Output
Print the number of three-player tables and the number of four-player tables , separated by a space.
If not everyone can play the kind they want, print -1 instead.