| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 90 | 34 | 34 | 39.080% |
President K is designing a pattern represented by a grid with $N$ rows and $N$ columns. To achieve this, he has decided to paint each cell with a color represented by an integer number. Let us refer to the cell in the $i$-th row (1ドル ≤ i ≤ N$) and $j$-th column (1ドル ≤ j ≤ N$) as cell $(i, j)$.
Currently, the cells in the first column and first row are already painted. Specifically, cell $(i, 1)$ (1ドル ≤ i ≤ N$) is painted with color $A_i$ and cell $(1, j)$ (1ドル ≤ j ≤ N$) is painted with color $B_j$. Note that $A_1 = B_1$.
For the remaining unpainted cells, President K is going to paint them by the following procedure:
President K would like to determine the color that is painted on the largest number of cells after all $N^2$ cells have been painted, as well as the number of cells painted with that color.
Write a program that, given the size of the grid and the color information for the first column and first row, determines the color number painted on the largest number of cells and the number of cells painted with that color. If multiple colors are painted on the largest number of cells, output the largest color number among them.
Read the following data from the standard input.
$N$
$A_1$ $A_2$ $\cdots$ $A_N$
$B_1$ $B_2$ $\cdots$ $B_N$
Write one line to the standard output containing two integers separated by a space:
If multiple colors are painted on the largest number of cells, output the largest color number among them.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 15 | $N ≤ 500,ドル $A_i ≤ 100,円 000$ (1ドル ≤ i ≤ N$), $B_j ≤ 100,円 000$ (1ドル ≤ j ≤ N$). |
| 2 | 10 | $N ≤ 500$. |
| 3 | 20 | $A_i ≤ 2$ (1ドル ≤ i ≤ N$), $B_j ≤ 2$ (1ドル ≤ j ≤ N$). |
| 4 | 25 | $A_i < A_{i+1}$ (1ドル ≤ i ≤ N − 1$), $B_j < B_{j+1}$ (1ドル ≤ j ≤ N − 1$). |
| 5 | 30 | No additional constraints. |
3 5 2 5 5 3 1
5 4
In this sample, the color of each cell in the grid will be as follows:
The color number painted on the largest number of cells is 5ドル,ドル which appears on 4ドル$ cells. Thus, print 5ドル$ and 4ドル$ in this order, separated by a space.
This sample input satisfies the constraints of Subtasks 1, 2, and 5.
3 1 7 8 1 3 5
8 3
In this sample, the color of each cell in the grid will be as follows:
The color numbers painted on the largest number of cells are 7ドル$ and 8ドル,ドル each painted on 3ドル$ cells. In this case, output the larger color number, 8ドル,ドル followed by the number of cells, 3ドル,ドル separated by a space.
This sample input satisfies the constraints of Subtasks 1, 2, 4, and 5.
4 2 1 2 1 2 1 1 2
2 10
This sample input satisfies the constraints of Subtasks 1, 2, 3, and 5.