Want to try solving this problem? You can submit your code online if you log in or register.

**Input File:** `genin.txt`

**Output File:** `genout.txt`

**Time Limit:** 0.05 second

You are a genius. Unfortunately you find it quite difficult to convince your friends of this, since each of them also believes themselves to be a genius.

During one maths tutorial, you and your friends Sara and John are sitting in a group solving problems. You quickly solve the first problem and look at the others with a satisfied smile. Rising to the challenge, Sara solves the next two problems and looks back at you with a grin. "Ha!" says John as he races through the next three problems. Not to be outdone, you hurriedly work through the following four problems. The three of you continue in this amusingly competitive way until all of the problems are solved.

As it happens, there are 18 problems in total on your question sheet. The number of problems solved in each round is illustrated in the table below.

Note that John only solves three problems instead of six in his final round, since 15 of the 18 problems have already been solved and there are only three remaining.

We see then that you manage to solve 1+4 = 5 problems, Sara solves 2+5 = 7 problems and John solves 3+3 = 6 problems. Clearly Sara is the greatest genius.

Your task is to write a program that can simulate this activity for any number of people and any number of problems. Your program must read the number of people solving problems as well as the total number of problems to solve, and it must output which person solves the most problems as well as how many problems (s)he solves.

The input file will consist of a single line. This line will contain
two integers separated by a space. The first integer will be *n*, the
number of people solving problems
(1 <= *n* <= 1,000).
These people will be numbered 1,2,...,*n*.
The second integer will be *p*, the total number of problems on the
question sheet (0 <= *p* <= 100,000).

Your output file should consist of a single line. This line should contain
two integers separated by a space. The first integer should describe
which person solves the most problems (recall that the *n* people
are numbered 1,2,...,*n*). If there is a tie, the lowest-numbered
person should be reported. The second integer should be the total number
of problems that this person solves.

3 18

2 7

The sample data above corresponds to the example described earlier in the problem statement. You are person 1, Sara is person 2 and John is person 3. Your output shows that Sara (person 2) completes the most problems, solving seven problems overall.

5 50

4 13

The score for each input file will be 100% if the correct answers are written to the output file and 0% otherwise.

Privacy
statement

© Australian Mathematics Trust 2001-2019

Page generated: 15 November 2019, 5:33am AEDT