Dice
InterviewTime limit2sMemory limit1024 MB
Given the first player's total from rolling some six-sided dice, find the minimum and maximum possible total on the bottom faces.
- Level
Medium5 of 10
- Topics
- Math, Greedy, Implementation, Brute force
- Solved
- No attempts yet
Problem
Young mathematician Matvey is interested in probability theory, so he always carries several standard six-sided dice with him. A standard six-sided die has three opposite pairs of faces, marked so that the face with 1 is opposite the face with 6, the face with 2 is opposite the face with 5, and the face with 3 is opposite the face with 4.
While analyzing various games with six-sided dice, Matvey invented a new game. Two players play it as follows. The first player rolls one or more standard dice (he decides how many). Then the first player scores points equal to the sum of the numbers on the top faces of all the dice, and the second player scores the sum of the numbers on the bottom faces of those dice. Whoever scores more points wins.
For example, if one die was rolled and a 2 came up on its top face, the first player gets 2 points and the second gets 5. If two dice were rolled and both top faces show 1, the first player also gets 2 points, but the second player gets 12 points, since the bottom faces of those dice show 6.
Matvey told his friend, young programmer Foma, about this game, and they started playing it over the Internet. Since Foma cannot see the result of the roll and does not know how many dice Matvey rolls as the first player, he learns the points scored by each player only from Matvey. To check whether this information is true, Foma wants to find out the minimum and maximum number of points he could have received as the second player, given how many points Matvey scored.
Write a program that, given the number of points the first player scored after a roll, determines the minimum and maximum number of points the second player can receive for that roll.
Input
The first line of the input file contains a positive integer , the number of points the first player received ().
Output
The output file must contain two integers separated by a space: the minimum and maximum number of points, respectively, that the second player could have scored on such a roll of the dice.