#B4011. Maximum Language Charm
Maximum Language Charm
Maximum Language Charm
In order to help everyone quickly familiarize themselves with a new programming language, Small A collected statistics on the languages used by n residents in the country. There are m language sets (numbered from 1 to m), and the i-th language set has a_i syntaxes. Each resident uses exactly one language, denoted by b_1, b_2, \ldots, b_n.
The charm of a language is defined as:
\[ charm = a_i \times \text{(number of residents using language } i\text{)} \]
Your task is to determine the maximum charm value among all languages.
inputFormat
The first line contains two integers m and n, representing the number of languages and the number of residents, respectively.
The second line contains m integers: a_1, a_2, \ldots, a_m representing the number of syntaxes for each language.
The third line contains n integers: b_1, b_2, \ldots, b_n denoting the language used by each resident.
outputFormat
Output a single integer: the maximum charm value among all languages.
sample
3 5
3 2 1
1 2 1 3 1
9