The most used drinking fountain
Statement
A park has 9 drinking fountains, numbered 1 through 9 in order along the walking trail. Every day the park office counts how many times water was drawn from each fountain and records it with a meter.
In yesterday's record, the use counts of the 9 fountains were all different from one another. The office wants to find the most used fountain and put it on the list for the next inspection. Since the use counts are all different, the most used fountain always comes out as exactly one fountain.
Given the use counts of the 9 fountains, write a program that prints the largest value among them and the number of the fountain that recorded it.
For example, suppose yesterday's use counts of the 9 fountains are as in the table below.
| Fountain number | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| Use count | 3 | 29 | 38 | 12 | 57 | 74 | 40 | 85 | 61 |
Now scan from fountain 1 in order, keeping the largest value seen so far and the number of the fountain that holds it. Following that scan gives the table below. The pair is replaced only when the value of the fountain being looked at is larger than the largest value so far.
| Fountain being looked at | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| Largest value so far | 3 | 29 | 38 | 38 | 57 | 74 | 74 | 85 | 85 |
| Number of that fountain | 1 | 2 | 3 | 3 | 5 | 6 | 6 | 8 | 8 |
At fountain 4 and fountain 7 the value was smaller, so nothing was replaced. After scanning all the way to fountain 9, the largest value is 85, and the fountain that recorded it is fountain 8.
| Item | Value |
|---|---|
| Largest use count | 85 |
| Number of that fountain | 8 |
So 85 and 8 are printed in that order.
Input and Output Examples
Example 1
Input
3 29 38 12 57 74 40 85 61
Output
85 8
Example 2
Input
7 61 95 97 2 58 39 31 63
Output
97 4
Example 3
Input
95 64 92 16 26 65 6 22 32
Output
95 1
Input
First, the use count of fountain 1 is given on the first line. Next, from the second line to the ninth line, the use counts of fountain 2 through fountain 9 are given one per line, in order of fountain number. So the input always consists of nine lines, and the number of fountains is not given separately. Each use count is a natural number between 1 and 99. Also, the 9 values are all different.
Output
Print two lines. The first line holds the largest value among the use counts. The second line holds the number of the fountain that recorded it. Numbering starts at 1. Each of the two lines holds one number only, followed by a line break.
Requirements
- Read the input from standard input and write the answer to standard output
- The input is always nine lines, with one number on each line
- The output is two lines. The value comes first and the number comes second
- Fountain numbering starts at 1. Counting from 0 gives a wrong answer
- Grading compares the output with the expected value down to the last character
- You must write a program that reads from standard input and writes to standard output
- Trailing spaces at the end of a line and blank lines at the end of the output are ignored when grading
- The languages you can use are Python and JavaScript
- The memory limit is 256MB. The browser does not measure it, it only states it
- The time limit is set by measuring the setter's reference solution on the same runtime
- On this problem you submit code, not a prompt. That code runs in the browser on this device, and all that goes to the server is a fingerprint of the output and the time it took. Whether it is correct is decided by the server. The run time is a number each device reports, so the code and the device details are posted next to it on the leaderboard.
- There are 15 cases, and 3 of them show the input together with the expected output. The rest are used only when you submit and are not shown on this page.
- You have to pass all 15 cases to solve this.
Examples
3 public cases. Judging also uses hidden cases. You have to pass all 15 cases to solve this.
3 29 38 12 57 74 40 85 61
85 8
95 64 92 16 26 65 6 22 32
95 1
7 61 95 97 2 58 39 31 63
97 4
Solution
Your code runs on this device. Only the fingerprint of the output and the elapsed time go to the server. The server decides whether it is correct.
Submitting requires you to log in. Running against the public cases works without one.
You can test with 3 public cases. Submitting runs the hidden cases too.
People who solved this problem
The time shown is the time spent solving. Input reading time is outside the solver's control, so it is excluded. And since each device reports this value itself, we record which device measured it.
Log in and you can see the code once you solve this problem.