Aloyna and Can Buying

prodip_bsmrstu Replay of BSMRSTU Intra U...
Limits 1s, 512 MB

Aloyna is a can lover girl and whenever she goes to a shop, she must buy a can to drink. This time she goes to a shop to buy a can. There are $n$ cans in the shop of $k$ types. The types are numbered from $1$ to $k$.

She will buy a specific type of can if the quantity of this type of can is the maximum in the shop. Can you find which type of can Aloyna will buy?


In the first line, there will be 2 integers $n$ ($1 \le n \le 1000$) and $k$ ($1 \le k \le 100$).

In the next line, there will be n integers, $a_1$, $a_2$, $a_3$, ..., $a_n$ ($1 \le a_i \le k$), the types of each can in the shop.


Print a number, the type number of the can which Aloyna will buy from the shop. If there are multiple answers then choose the can whose type number is minimum.


6 3
1 2 2 2 1 3

There are 6 cans of 3 types and type #1's quantity is 2, type #2's quantity is 3 and type #3's quantiy is 1. Since type #2's quantity is the maximum, so the answer is 2.

3 3
1 2 3

Since every type's quantity is the same, so the answer is the can whose type number is minimum which is 1 in this case.


Login to submit.


87% Solution Ratio
iammarajulEarliest, Dec '19
iammarajulFastest, 0.0s
RubiathLightest, 0 B
bokaifShortest, 78B
Toph uses cookies. By continuing you agree to our Cookie Policy.