P23637 [AtCoder] Grading
普及-
题目描述

Problem Description

Takahashi is grading test results. However, he has forgotten the correct answer to a certain question. This question has been answered by $ N $ people, and each person's answer is an integer between $ 0 $ and $ M $ inclusive. Takahashi decided that if more than half of the people have the same answer, he will consider that answer to be correct.

Given the answers to this question from $ N $ people, output what Takahashi will consider to be the correct answer. If Takahashi cannot determine the correct answer, output ?.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ A_1 $ $ A_2 $ ... $ A_N $

  • The first line contains two integers $N\ (1\ ≦\ N\ ≦\ 10^5)$, $M\ (1\ ≦\ M\ ≦\ 10^5)$ separated by a space.
  • The second line contains $ N $ integers separated by spaces. The $i\ (1\ ≦\ i\ ≦\ N)$ -th of these is the integer $A_i\ (0\ ≦\ A_i\ ≦\ M)$ representing the answer of the $ i $ -th person.

Output Format

Output the integer that Takahashi considers to be the correct answer in one line. If Takahashi cannot determine the correct answer, output ? in one line. End the output with a newline.

Sample Input and Output

Sample Input #1

3 2
2 1 2

Sample Output #1

2

Sample Input #2

4 2
2 1 2 1

Sample Output #2

?

Sample Input #3

10 1
0 0 0 0 0 0 1 1 1 1

Sample Output #3

0

Sample Input #4

10 5
0 1 2 3 4 5 5 5 5 5

Sample Output #4

?

Notes/Hints

Partial Points

This problem has partial points.

  • If you solve the dataset where $N\ ≦\ 100$, $M\ ≦\ 100$, you will be awarded $ 40 $ points.
  • If you solve the dataset without additional constraints, you will be awarded an additional $ 60 $ points.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 2 1 2
样例输出
2