Tombola

AtCoder
IDabc437_b
Time2000ms
Memory256MB
Difficulty
There is a grid with $H$ rows and $W$ columns. Each square has one integer written on it, and these integers are distinct. The square at the $i$\-th row from the top and $j$\-th column from the left has the integer $A_{i,j}$ written on it. Now, the host called out $N$ distinct integers $B_1, \dots, B_N$. If you find, for each row, how many of the integers called out by the host are contained in that row, what is the maximum value among these? ## Constraints * $1 \leq H \leq 3$ * $1 \leq W \leq 5$ * $1 \leq N \leq 90$ * $1 \leq A_{i,j} \leq 90$ * $A_{i,j}$ are distinct. * $1 \leq B_i \leq 90$ * $B_i$ are distinct. * All input values are integers. ## Input The input is given from Standard Input in the following format: $H$ $W$ $N$ $A_{1,1}$ $\cdots$ $A_{1,W}$ $\vdots$ $A_{H,1}$ $\cdots$ $A_{H,W}$ $B_1$ $\vdots$ $B_N$ [samples]
Samples
Input #1
3 4 5
12 3 5 7
6 10 11 9
1 2 4 8
2
4
9
6
11
Output #1
3

*   Among the integers in the $1$\-st row from the top, $0$ integers were called out by the host.
*   Among the integers in the $2$\-nd row from the top, $3$ integers $6,11,9$ were called out by the host.
*   Among the integers in the $3$\-rd row from the top, $2$ integers $2,4$ were called out by the host.

Thus, the answer is the maximum value among $0,3,2$, which is $3$.
Input #2
3 5 2
81 63 31 16 15
30 3 6 54 24
26 41 48 64 66
44
79
Output #2
0
Input #3
3 5 12
78 19 70 58 83
12 30 80 20 27
48 71 8 43 82
82
30
43
8
80
70
20
78
12
71
19
48
Output #3
5
API Response (JSON)
{
  "problem": {
    "name": "Tombola",
    "description": {
      "content": "There is a grid with $H$ rows and $W$ columns. Each square has one integer written on it, and these integers are distinct. The square at the $i$\\-th row from the top and $j$\\-th column from the left h",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc437_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There is a grid with $H$ rows and $W$ columns. Each square has one integer written on it, and these integers are distinct. The square at the $i$\\-th row from the top and $j$\\-th column from the left h...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments